I am currently using the below code to get a list of SQL instances, however the problem is that the code below get's all SQL instances on the whole of a network. I am currently writing a wizard for my application, this wizard is installed on the server that they have SQL Server installed. Therefore I do not want the code to go and find all the SQL instances on a network, but just the SQL instance(s) on the current machine. Could someone people help me in showing me want I need to modify in the below code to do this?
Thanks in advance
Simon
VB.NET:
Dim sqlList As SQLDMO.NameList = Nothing
Dim sqlApp As SQLDMO.Application = Nothing
Try
sqlApp = New SQLDMO.Application
sqlList = sqlApp.ListAvailableSQLServers
Dim colSQLServer As ComboBoxItemCollection = Me.cmbSQLServer.Properties.Items
Dim ctr As Integer = 1
While ctr <= sqlList.Count
colSQLServer.Add(New String(sqlList.Item(ctr)))
System.Math.Min(System.Threading.Interlocked.Increment(ctr), ctr - 1)
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
If Not (sqlList Is Nothing) Then
sqlList = Nothing
Me.cmbSQLServer.SelectedIndex = 0
End If
If Not (sqlApp Is Nothing) Then
sqlApp = Nothing
End If
End Try
Thanks in advance
Simon