prv*_*ini 6 c# postgresql npgsql
我正在使用C#可执行文件在postgres中启动一个真空过程.我希望将消息返回到我的可执行文件,但我无法从输出窗口返回消息.
简而言之,我正在寻找使用NPGSQL的postgres中的相同内容:
// 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;
};
Run Code Online (Sandbox Code Playgroud)
我希望使用NPGSQL在我的C#代码中获取此消息.
我尝试了下面的代码。它将为您提供完整的执行日志。由此我刚刚解析了我所需的日志。这不是最好的方法,但我找不到其他方法。
//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();
}
Run Code Online (Sandbox Code Playgroud)