Section 9.3. A Simple SMO Application

9.3. A Simple SMO Application

This example displays the product title for the local SQL Server instance and the hardware platform for the computer running the SQL Server instance. You need a reference to the Microsoft.SqlServer.ConnectionInfo.dll and Microsoft.SqlServer.Smo.dll assemblies to compile and execute this example.

     using System;     using Microsoft.SqlServer.Management.Smo;     class Program     {         static void Main(string[] args)         {             Server server = new Server("localhost");             Console.WriteLine("Product:    " + server.Information.Product);             Console.WriteLine("Platform:   " + server.Information.Platform);             Console.WriteLine(Environment.NewLine +                 "Press any key to continue.");             Console.ReadKey(  );         }     } 

The console output looks something like the output shown in Figure 9-1.

Figure 9-1. Console output for a simple SMO application

The Information property of the Server class returns an Information object that exposes information about the SQL Server instance through its properties.

Programming SQL Server 2005
Programming SQL Server 2005
ISBN: 0596004796
EAN: 2147483647
Year: 2007
Pages: 147
Authors: Bill Hamilton © 2008-2017.
If you may any questions please contact us: