Private Sub Command1_Click() Dim oAppliction As New SQLDMO.Application Dim oNameList As SQLDMO.NameList Dim i As Integer Dim strOldServer As String On Error Resume Next Screen.MousePointer = vbHourglass '保存旧数据 strOldServer = cboServerName Err.Clear
'列出可以使用的SQL Server实例 Set oNameList = oAppliction.ListAvailableSQLServers
'如果正确则列出 If Err.Number = 0 Then '如果有可以利用的SQL Server实例 If oNameList.Count >= 1 Then '添加到下拉列表框中 With List1 .Clear For i = 1 To oNameList.Count .AddItem oNameList.Item(i) Next i '恢复旧数据 .Text = strOldServer End With End If End If '断开连接,并释放对象 oAppliction.Quit Set oAppliction = Nothing Screen.MousePointer = vbDefault End Sub 我用这段代码后只能列出local,不知问题出在哪?是不是这种方法在XP里不支持?