Freigeben über


How to: Create a Visual Basic SMO Project in Visual Studio .NET

Aktualisiert: 05. Dezember 2005

This section describes how to start a simple SMO console application.

This example imports namespaces, which enables the program to reference SMO types. The import of the Agent namespace is optional. Use it when you are writing a program that uses the SQL Server Agent. The Common namespace is required to establish a secure connection to the instance of SQL Server. The SqlClient namespace is used for SQL exception errors.

Creating a Visual Basic SMO project in Visual Studio.NET

  1. Start Visual Studio 2005.

  2. On the File menu, select New Project. The New Project dialog box appears.

  3. In the Project Types pane, select Visual Basic. In the Templates pane, select the application type. For the examples that follow, select Console Application.

  4. (Optional) In the Name box, type the name of the new application.

  5. Click OK to load the Visual Basic console application template.

  6. On the Project menu, select Add Reference item. The Add Reference dialog box appears.

  7. Select Browse, locate the SMO assemblies in the C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies folder, and select the following files:

    Microsoft.SqlServer.ConnectionInfo.dll

    Microsoft.SqlServer.ServiceBrokerEnum.dll

    Microsoft.SqlServer.Smo.dll

    Microsoft.SqlServer.SmoEnum.dll

    Microsoft.SqlServer.OlapEnum.dll

    Microsoft.SqlServer.SqlEnum.dll

    Microsoft.SqlServer.WmiEnum.dll

    ms162562.note(de-de,SQL.90).gifHinweis:
    Use the Ctrl key to select more than one file.
  8. Click Open.

  9. On the View menu, click Code.-Or-Select the Module1.vb window to display the code window.

  10. In the code, before any declarations, type the following Imports statements to qualify the types in the SMO namespace.

    Imports Microsoft.SqlServer.Management.Smo
    Imports Microsoft.SqlServer.Management.Common
    
  11. SMO has various namespaces under Microsoft.SqlServer.Management.Smo, such as Microsoft.SqlServer.Management.Smo.Agent. Add these as needed.

  12. You can now add your SMO code.

Siehe auch

Konzepte

SMO Namespaces

Hilfe und Informationen

Informationsquellen für SQL Server 2005