Danh mục

Listing SQL Servers

Số trang: 2      Loại file: pdf      Dung lượng: 12.00 KB      Lượt xem: 14      Lượt tải: 0    
10.10.2023

Phí tải xuống: miễn phí Tải xuống file đầy đủ (2 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

[ Team LiB ] Recipe 10.1 Listing SQL Servers Problem You need to obtain a list of SQL Servers available on the network. Solution Use SQL Server Distributed Management Objects (SQL-DMO) to retrieve a list of available SQL Servers.
Nội dung trích xuất từ tài liệu:
Listing SQL Servers[ Team LiB ]Recipe 10.1 Listing SQL ServersProblemYou need to obtain a list of SQL Servers available on the network.SolutionUse SQL Server Distributed Management Objects (SQL-DMO) to retrieve a list ofavailable SQL Servers.Youll need a reference to the Microsoft SQLDMO Object Library from the COM tab inVisual Studio .NETs Add Reference Dialog.The sample code retrieves and displays a list of all SQL Servers running on a localnetwork segment by using SQL-DMO through COM interop.The C# code is shown in Example 10-1.Example 10-1. File: ServerListForm.cs// Namespaces, variables, and constantsusing System;// . . .serverListListBox.Items.Clear( );// Create a SQL Distributed Management Objects (SQL-DMO)// application object.SQLDMO.Application dmo = new SQLDMO.Application( );// Retrieve the available servers.SQLDMO.NameList serverNameList = dmo.ListAvailableSQLServers( );// Iterate over the collection of available servers.for(int i = 0; i < serverNameList.Count; i++){ if (serverNameList.Item(i) != null) serverListListBox.Items.Add(serverNameList.Item(i));}serverListListBox.Items.Add(End of list.);DiscussionSQL Server Distributed Management Objects (SQL-DMO) is a collection of objects thatencapsulate SQL Server database and replication management. SQL-DMO is used toautomate SQL Server tasks, create and administer SQL Server objects, and install andconfigure replication. You can use SQL-DMO from a .NET application through COMinterop. For more information about SQL-DMO, see Microsoft SQL Server BooksOnline.The ListAvailableSQLServers( ) method of the SQL-DMO Application object returns aNameList object that enumerates all running servers that listen on named pipes and arelocated in the same domain. Any servers running on Windows 9x will not be reportedbecause they do not listen on named pipes. The discovery is based on a networkbroadcast, so if you are disconnected from a network, local servers will not beenumerated.This procedure does not return desktop (MSDE) instances.[ Team LiB ]

Tài liệu được xem nhiều:

Gợi ý tài liệu liên quan: