Application对象的ListAvailableSQLServers方法会返回一个NameList对象,它包含有网络上可用服务器的列表。下面的代码显示了一个使用这个方法来填充列表框控件的方法:Dim objSQLApp As SQLDMO.Application Dim objNameList As SQLDMO.NameList Dim intCount As IntegerSet objSQLApp = New SQLDMO.ApplicationSet objNameList = objSQLApp.ListAvailableSQLServers()For intCount = 1 To objNameList.Count Call List1.AddItem(objNameList.Item(intCount)) Next
在安裝目錄下有VB的示例代碼。
Dim objNameList As SQLDMO.NameList
Dim intCount As IntegerSet objSQLApp = New SQLDMO.ApplicationSet objNameList = objSQLApp.ListAvailableSQLServers()For intCount = 1 To objNameList.Count
Call List1.AddItem(objNameList.Item(intCount))
Next