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.
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With