I am trying to call a function when new data is add to the database.
NpgsqlConnection connListenRun = new NpgsqlConnection("Server=main;Port=5432;Database=netdb;UserId=postgres;Password=password;");
try
{
connListenRun.Open();
NpgsqlCommand cmd = new NpgsqlCommand("listen RunLogClient;", connListenRun);
cmd.ExecuteNonQuery();
connListenRun.Notification += new NotificationEventHandler(RunFinishNotification);
}
catch (NpgsqlException ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
//connListen.Close();
}
private void RunFinishNotification(object sender, NpgsqlNotificationEventArgs e)
{
MessageBox.Show("Data!");
}
However, my message box isn't showing when new data is added. On another program using the same trigger function has 'SyncNotification=true;' on the end of the conListenRun.
NpgsqlConnection connListenRun = new NpgsqlConnection("Server=main;Port=5432;Database=netdb;UserId=postgres;Password=password;SyncNotification=true;");
However, when i put 'SyncNotification=true;' on the statment i get this error:
: 'Keyword not supported: syncnotification Parameter name: keyword'
What am i doing wrong?
Thanks
...Npgsql will only process it and emit an event to the user the next time a command is sent and processed. Can you check if its true for you?usingblock, then you don't needfinally