Capturing Messages, using SMO in VB.NET

I have done some searching for a simple, clear example of how to capture all messages when running a query against Microsoft SQL Server using the SQL Management Objects (SMO).

I haven't been at all happy with what I've found, so I thought I would post the following example, hopefully as a clear and concise code example

VB.NET
SMO

A few notes:
1 - "Messages" is a text TextBox that I am using, as you might guess, to write messages to
2 - Note the "AddressOf" in the AddHandler method call. This registers the method so that messages can be passed to the application and handled.
3- I had to define MigDBServer as
Private MigDBServer As Microsoft.SqlServer.Management.Smo.Server
Click Image to view larger Version:


Comments

Popular posts from this blog

Detecting Transaction Isolation Level through Profiler Trace and other means on MS SQL Server 2005

Regular Expressions in SQL Server, DB2 UDB, and Oracle