postgresql データベースに接続し、挿入クエリを使用したいと考えています。私はいくつかの調査を行いましたが、私が何をしているのかわかりません。そのため、postgresql に接続しているかどうかさえわかりません。
ここに私のコードがあります:
String conn = ("Server=127.0.0.1;Port=5432;User id=*******;Password=***;Database=database1;");
try
{
NpgsqlConnection objConn = new NpgsqlConnection(conn);
objConn.Open();
string strSelectCmd = "INSERT INTO weather (date, city, temp_hi, temp_lo) VALUES ('1994-11-29', 'Hayward', 54, 37);";
NpgsqlDataAdapter objDataAdapter = new NpgsqlDataAdapter(strSelectCmd, objConn);
objConn.Close();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "Error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}