Friday, November 27, 2015

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
4 - It is also necessary to add a reference to the ddl that contains the Microsoft SMO extensions.

Add Reference by going to Project-> Add References.
Then choose Assemblies->Extensions, and select Microsoft.SqlServer.Smo



Code:
Click Image to view larger Version:




No comments:

DBT-50000 when using DBCA.bat on Windows (Oracle 19.11)

I’ve been having some trouble getting DBCA to run in order to create databases. Thought I’d share it with you, and thus document it for la...