Retrieving SQL Server 2005 Database Info Using SMO: Basics - Creating the Visual Studio 2005 solution to connect to SMO
(Page 2 of 5 )
Actually, it is a very simple task to connect any SQL Server database (7.0 onwards) using SMO. We just need to refer certain SMO assemblies, and that should work fine for us. You can proceed with the following steps to start with Visual Studio 2005.
- Open Programs -> Microsoft Visual Studio 2005 -> Microsoft Visual Studio 2005.
- Go to File -> New -> Project.
- Within the New Project dialog, select “Visual Basic” as Project Type and “Windows Application” as Template.
- Provide an appropriate Project Name (something like “SMOSample01”) and Solution Name (along with location) and click OK. A Solution is created with a WinForm named “Form1”.
- Go to Solution Explorer, right click on the project and go to “Add Reference” (as shown in Fig 1).
- Within the “Add Reference” dialog, search and select all of the following assemblies:
- Microsoft.SqlServer.ConnectionInfo
- Microsoft.SqlServer.Smo
- Microsoft.SqlServer.SmoEnum
- Microsoft.SqlServer.SqlEnum
- Finally, click OK.
- If you go to Project->Properties->References, it should look like the following image (Fig 2):
In some situations, you may also need to refer the following assemblies (depending upon your requirements):
- Microsoft.SqlServer.ServiceBrokerEnum.dll
- Microsoft.SqlServer.OlapEnum.dll
- Microsoft.SqlServer.WmiEnum.dll
Next: Connecting to the SQL Server database using SMO >>
More MS SQL Server Articles
More By Jagadish Chaterjee