How to enumerate Sql-server servers in a network

Source: Internet
Author: User
server| Server | The network itself produced a similar ODBC landing of the Sql-server Server login window (the following image), which contains the server name, database name, username, password, connection wait time .... Here to explain the "server" item, use the composite box Drop-down list to enumerate the Sql-server server name implementation in the network. (As for how to enumerate the database names in the server, there are many posts in the forum to search for, methods and this similar)



First you need to reference SQLDMO. Method: Refer to the Microsoft SQLDMO object Library in Tools-references.
Code:
Private Sub Combo1_dropdown ()
Dim SVR as New SQLDMO. Sql server
Dim I as Integer
If combo1.listcount > 0 Then
Dim Dn as String
Dn = Trim (combo2.text) ' Combo1 is the combo control of the column database name
Combo1.clear
Combo1.text = Dn
SendKeys "{End}"
' The above code implementation dropdown when the original content is not emptied
Else
End If
Svr. Connect "ServerName", "Uerid", "PWD" ' 3 quotes, respectively, for server name, username, password
For i = 1 to SVR. Databases.count
Combo1.additem SVR. Databases (i). Name
Next
End Sub





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.