SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - Can We Integrate Visual Basic.NET, SQL Ser...
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 
Actuate Whitepapers 
VeriSign Whitepapers 
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? 
VISUAL BASIC.NET

Can We Integrate Visual Basic.NET, SQL Server 2000 and WMI?
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2005-11-09

    Table of Contents:
  • Can We Integrate Visual Basic.NET, SQL Server 2000 and WMI?
  • How to connect to SQL Server 2000 using WMI
  • How to retrieve “Databases” information in SQL Server instance
  • How to retrieve “tables” information in SQL Server instance

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Can We Integrate Visual Basic.NET, SQL Server 2000 and WMI? - How to connect to SQL Server 2000 using WMI


    (Page 2 of 4 )

    First of all, you need to install “WMI SQL Server Administration Provider” on an existing instance of SQL Server 2000 (if not installed). This is not part of the default or custom installation.  You need to install it separately from SQL server installations.  You can find the “WMI SQL Server Administration Provider” installation files at the “x86\other\wmi” path of your SQL Server 2000 installation CD.  To be frank, I really didn’t check this on SQL Server 7.0.  So, my focus will always be on SQL Server 2000 in this article.

    Once it is installed (which is as simple as winzip installation), you can directly work with my downloadable solution. The first button (captioned “version”) within the form tries to give you the SQL server version you installed on your computer.  If you can get it, you can confirm that WMI works with your version.  Let us go through the code I wrote:

    Private Sub btnCaption_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCaption.Click
            Dim PrivateLateBoundObject As ManagementObject
            PrivateLateBoundObject = New ManagementObject(Nothing, New ManagementPath("\\server\root\MicrosoftSQLServer:
    MSSQL_SQLServer.Name=""(local)"""), Nothing)
            MessageBox.Show(PrivateLateBoundObject("VersionString"))
            PrivateLateBoundObject.Dispose()
        End Sub

    From the code above, you can understand that I am creating an object (PrivateLateBoundObject) based on the “ManagementObject” class.  The “ManagementPath” starts with “\\yourhostname”.  There exists a WMI class called “MSSQL_SQLServer” within the “MicrosoftSQLServer” namespace (which comes onto the scene after you installed the “WMI SQL Server Administration Provider”).

    The “(local)” says that I am trying to connect to my “local instance” within the same host name I provided.  There exists a WMI property called “VersionString” which is used to retrieve the version information of SQL Server 2000 you installed on your computer.  You should get an output (Message box) something like the following figure.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys...I opened the doors of WMI even to the level of SQL Server 2000..Have a...
       · Hi jagdesh, The article explained me more about the use of WMI calls in...
       · Hai Gupta! I am very happy that it helped you. Thanks very much, bye.
     

    VISUAL BASIC.NET ARTICLES

    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...





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