4

ac# アプリケーションを使用して、postgresql テーブルに適切なデータをロードしています。コードは次のとおりです。

NpgsqlConnection conn = new NpgsqlConnection("Server=localhost;Port=5432;UserId=postgres;Password=***** ;Database=postgres;");
NpgsqlCommand command = new NpgsqlCommand();
command.Connection = conn;
conn.Open();
try {
  command.CommandText = "insert into projets (ID, Title, Path, Description, DateCreated) values('" + pro.ID + "','" + pro.Title + "','" + pro.Path + "', '' ,'" + pro.DateCreated + "')";
  command.ExecuteNonQuery();
} catch {
  throw;
}
conn.Close();

ただし、コードを実行すると、同じエラーが発生し続けます。

error 42601 syntax error at or near...

アポストロフィをエスケープする方法が見つかりませんでした。

4

1 に答える 1