Hello everyone, recently I had to create an application for Windows 10. Knowing the OS works with framework 4.6, I had to install this version for VS2013. My application works perfectly, except Class SqlDataSourceEnumerator! I had a small form and when start, it find all not hidden instances of SQL Server on the local machine and on the network ....Just in case, you have found a solution for this problem or you like to suggest another way, I'm here to follow you. Thank you.
Here my code :
Private Sub SearchSQLServerInstance()
Try
Dim listOfServers As New List(Of String)()
Dim sqlEnumerator As Sql.SqlDataSourceEnumerator = Sql.SqlDataSourceEnumerator.Instance
sqlEnumerator.GetDataSources()
Dim sqlServersTable As DataTable = sqlEnumerator.GetDataSources()
For Each rowOfData As DataRow In sqlServersTable.Rows
FrmSplashScreen.Refresh()
Dim serverName As String = rowOfData("ServerName").ToString()
Dim instanceName As String = rowOfData("InstanceName").ToString()
'check if the instance name is empty
If Not instanceName.Equals(String.Empty) Then
serverName += String.Format("\{0}", instanceName)
End If
'
listOfServers.Add(serverName & "|" & rowOfData(3).ToString)
FrmSplashScreen.Refresh()
Next
'
'
If Not listOfServers Is Nothing Then
listOfServers.Sort()
Dim i As Integer = Nothing
'
For i = 0 To listOfServers.Count - 1
FrmSplashScreen.Refresh()
Dim NomeServerSplit() As String = Split(listOfServers(i), "|")
Dim NomeServer As String = NomeServerSplit(0).ToString.TrimEnd
'
Me.ComboBoxInstance.Items.Add(NomeServerSplit(0).ToString.TrimEnd)
Me.ComboBoxVersion.Items.Add(NomeServerSplit(1).ToString.TrimEnd)
FrmSplashScreen.Refresh()
Next
End If
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "Search SQL Servers Instances")
End Try
Thank You for you attention...