Reputation: 186
I am initiating a vacuum process in postgres from a C# executable. I want the message to be returned back to my executable, but i I'm not able to get the message back from output window.
In short, I'm looking for equivalent of this in postgres using NPGSQL like:
// Display messages this code is for SQL server to reteive data back from message tab
conn.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs e) {
stdmForm.txtLastSQLMessages.Text +`=` "\n" + e.Message;
};
I want to get this message in my C# code using NPGSQL.
Upvotes: 7
Views: 2263
Reputation: 14535
Try the NpgsqlConnection.Notification event, which is PostgreSQL's counterpart to SqlConnection.InfoMessage. See here: archive of http://npgsql.projects.pgfoundry.org/docs/api/Npgsql.NpgsqlConnection.Notification.html.
Upvotes: 2
Reputation: 186
I tried the code below. It will give you the complete execution log. From this I just parsed my required log. It's not the best way but I was not able to find anything else.
//log the Vacuum command information
NpgsqlEventLog.Level = LogLevel.Debug;
NpgsqlEventLog.LogName = VacuumLogFilePath + "rolling.log";
NpgsqlEventLog.EchoMessages = false;
try
{
//Run the Vacuum Command
NpgsqlCommand comm = new NpgsqlCommand("VACUUM VERBOSE ANALYZE", connection);
comm.ExecuteNonQuery();
}
Upvotes: 2