MS SQL Server
  Home arrow MS SQL Server arrow Page 3 - 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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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 - Connecting to the SQL Server database using SMO


    (Page 3 of 5 )

    After completing all the steps in the previous section, create a layout with only a button (“btnConnect”) and multi-lined text box as shown in the following inage (Fig 3):

    Now, it is the time to write some code!  Let us switch to the code window (by pressing F7) and modify as shown below:

    Imports Microsoft.SqlServer.Management.Smo
    Public Class Form1
     
        Private Sub btnConnect_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles btnConnect.Click
            Dim svr As Server = New Server()
            Me.TextBox1.Text = "Server Name: " & svr.Name &
    ControlChars.NewLine
            Me.TextBox1.Text &= "Instance Name: " & svr.InstanceName
    & ControlChars.NewLine
            Me.TextBox1.Text &= "Product: " & svr.Information.Product
    & ControlChars.NewLine
            Me.TextBox1.Text &= "Version: " &
    svr.Information.VersionString & ControlChars.NewLine
            Me.TextBox1.Text &= "Edition: " & svr.Information.Edition
    & ControlChars.NewLine
            Me.TextBox1.Text &= "Default Language: " &
    svr.Information.Language & ControlChars.NewLine
        End Sub
    End Class

    That’s it. You are finished.  Execute the solution by pressing F5.  Once you click on the “Connect” button, it should connect to the default instance of SQL Server and retrieve information as shown in the following image (Fig 4):

    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 4 hosted by Hostway