List SQL Express 2005 instances using VB6 code
H开发者_如何转开发ow to list all the instances of SQL Server 2005 Express Edition using vb6 application?
This will list all SQL Server instances using SQL-DMO. You will need to filter for Express instances.
Function listServers(vControl As Object)
Dim oApp As SQLDMO.Application
Dim oNames As SQLDMO.NameList
Set oApp = New SQLDMO.Application
Set oNames = oApp.ListAvailableSQLServers()
For Each oName In oNames
vControl.AddItem oName
Next
End Function
From here.
This SO question says that it won't find Express instances; need to use SQLBrowseConnect
.
This sample is using SQLBrowseConnect
API.
精彩评论