Is it possible to access the SQL Server \"by-product messages\" via ADO.NET? Due to the lack of words, by \"by-product messages\" I mean the output which appears in the Mess
Yes, there's an event on the SqlConnection class called SqlInfoMessage, which you can hook into:
SqlConnection _con =
new SqlConnection("server=.;database=Northwind;integrated Security=SSPI;");
_con.InfoMessage += new SqlInfoMessageEventHandler(InfoMessageHandler);
The event handler will look like this:
static void InfoMessageHandler(object sender, SqlInfoMessageEventArgs e)
{
string myMsg = e.Message;
}
The e.Message is the message printed out to the message window in SQL Server Management Studio.