Reading SQL return messages from .NET
-
I'm trying to gather statistics from multiple queries to gauge our database performance. So, I dropped a "Set statistics io on" (with matching off) at the top of my query. In Sql Management Studio, the results of the query come back in the Results tab, while the IO statistics come back in the Messages tab. How can I gather the IO statistics (the messages) from .NET with the provided SQLCommand/SQLDataAdapter/etc. classes? I tried pausing my test app just after the query ran and looking through all the involved objects for the IO messages but couldn't find anything.
-
I'm trying to gather statistics from multiple queries to gauge our database performance. So, I dropped a "Set statistics io on" (with matching off) at the top of my query. In Sql Management Studio, the results of the query come back in the Results tab, while the IO statistics come back in the Messages tab. How can I gather the IO statistics (the messages) from .NET with the provided SQLCommand/SQLDataAdapter/etc. classes? I tried pausing my test app just after the query ran and looking through all the involved objects for the IO messages but couldn't find anything.
The SQLConnection object fires an InfoMessage event that you must catch.