I want to connect to a postgresql database and use an insert query. I have done some research but i have no clue what i am doing. So i don't even know if i am connected with the postgresql.
here is my code:
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);
}
I have done some research but i have no clue what i am doing- do you have a clue whether you are getting an exception when you run this code?