Using SQL-DMO to manipulate SQL Servers

Source: Internet
Author: User
Tags connect sql

The SQL Distributed relational Object (SQL-DMO) library allows your VB6 application to automatically interoperate with SQL Servers. This is useful for getting information about SQL Servers, such as the state of the server or the available servers on the network.

To use the SQL-DMO library, you need to set up a reference to the Microsoft Sql-dmo Object Library.

The ListAvailableSQLServers method of the Application object returns a NameList object that contains a list of available servers on the network. The following code shows a way to populate a list box control by using this method:

Dim Objsqlapp as SQLDMO. Application
Dim Objnamelist as SQLDMO. NameList
Dim intcount as Integer

Set Objsqlapp = New SQLDMO. Application

Set objnamelist = Objsqlapp.listavailablesqlservers ()

For intcount = 1 to Objnamelist.count
Call List1.AddItem (Objnamelist.item (intcount))
Next

Another useful object in the SQL-DMO library is the SQL Server object. This object can be used to get information about a particular SQL Server. The Connect method establishes a connection to the database server and accepts three parameters: the database name, user name, and password. Once the object's connection succeeds, information about the server can be retrieved:

Dim Objsqlserver as SQLDMO. Sql server

Set objsqlserver = New SQLDMO. Sql server
Objsqlserver.loginsecure = True
Call Objsqlserver.connect ("MyServerName", "username", "password")

Debug.PrintobjSQLServer.Name
Debug.PrintobjSQLServer.HostName
Debug.PrintobjSQLServer.Status








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.