MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - Retrieving SQL Server 2005 Database Info U...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Retrieving SQL Server 2005 Database Info Using SMO: Basics
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2006-01-31

    Table of Contents:
  • Retrieving SQL Server 2005 Database Info Using SMO: Basics
  • Creating the Visual Studio 2005 solution to connect to SMO
  • Connecting to the SQL Server database using SMO
  • Understanding the SMO connectivity
  • How do we retrieve “Database” Information about a particular SQL Server instance using SMO?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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

    More MS SQL Server Articles
    More By Jagadish Chaterjee


       · Hi guys, delve into SMO of SQL Server 2005 with this contribution. Have any doubts...
       · You mention that SMO supports Sql Server 7.0. When I tried using it to access my...
       · Hai, it is possible to work with SMO on SQL Server 7.0/2000, if and only if we...
       · Hi your article is pretty good,I use to use dmo and I wonder how to get all the...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT