M
MRM256
Guest
My problem is this code functioned perfectly in VS2013, but doesn't in VS2017.
Public Function lst_SQLServers() As List(Of String)
'Purpose: List all instances of MS-SQL Servers on the
' the Network
'Parameters: None
'Returns: A List of SQL Server instances.
'declare variables
Dim dt As Data.DataTable = Nothing
Dim dr As Data.DataRow = Nothing
Dim listSQL As List(Of String) = New List(Of String)
Try
'get sql server instances in to DataTable object
dt = Sql.SqlDataSourceEnumerator.Instance.GetDataSources()
For I = 0 To dt.Rows.Count - 1 'Step I + 1
listSQL.Add(dt.Rows(I)(0).ToString)
'Debug.Print(dt.Rows(I)(0).ToString)
Next
Catch ex As System.Data.SqlClient.SqlException
'Log error
Dim el As New Log.ErrorLogger
el.WriteToErrorLog(ex.Message, _
ex.StackTrace, _
"Error - lst_SQLServers")
Catch ex As Exception
'Log error
Dim el As New Log.ErrorLogger
el.WriteToErrorLog(ex.Message, _
ex.StackTrace, _
"Error - lst_SQLServers")
Finally
'clean up
dr = Nothing
dt = Nothing
End Try
Return listSQL
End Function
I tried importing the NameSpace Microsoft.SqlServer.Management.Smo but VS said this was unnecessary.
The only thing different is I had to load Microsoft SQL Server 2017 Developers edition 2017 onto my server PC named MRM-WINX-002. I can access SQL server using SSMS 2017 from MRM-WINX-001. So I don't think it is a network issue, but it could be something MRM-WINX-002 related.
Can someone tell me how to fix this? A developer should not have to redevelop an application just because he updated to a new developer's suite.
Thanks,
MRM256
Continue reading...
Public Function lst_SQLServers() As List(Of String)
'Purpose: List all instances of MS-SQL Servers on the
' the Network
'Parameters: None
'Returns: A List of SQL Server instances.
'declare variables
Dim dt As Data.DataTable = Nothing
Dim dr As Data.DataRow = Nothing
Dim listSQL As List(Of String) = New List(Of String)
Try
'get sql server instances in to DataTable object
dt = Sql.SqlDataSourceEnumerator.Instance.GetDataSources()
For I = 0 To dt.Rows.Count - 1 'Step I + 1
listSQL.Add(dt.Rows(I)(0).ToString)
'Debug.Print(dt.Rows(I)(0).ToString)
Next
Catch ex As System.Data.SqlClient.SqlException
'Log error
Dim el As New Log.ErrorLogger
el.WriteToErrorLog(ex.Message, _
ex.StackTrace, _
"Error - lst_SQLServers")
Catch ex As Exception
'Log error
Dim el As New Log.ErrorLogger
el.WriteToErrorLog(ex.Message, _
ex.StackTrace, _
"Error - lst_SQLServers")
Finally
'clean up
dr = Nothing
dt = Nothing
End Try
Return listSQL
End Function
I tried importing the NameSpace Microsoft.SqlServer.Management.Smo but VS said this was unnecessary.
The only thing different is I had to load Microsoft SQL Server 2017 Developers edition 2017 onto my server PC named MRM-WINX-002. I can access SQL server using SSMS 2017 from MRM-WINX-001. So I don't think it is a network issue, but it could be something MRM-WINX-002 related.
Can someone tell me how to fix this? A developer should not have to redevelop an application just because he updated to a new developer's suite.
Thanks,
MRM256
Continue reading...