M
MRM256
Guest
This is getting frustrating for both me and the individuals who have been trying to help me find a solution.
To this end I created a barebones application that just lists the instances of SQL Server.
I have an application that contains one form with a combo box control and a DataGridView control.
The application searches for SQL Server instances when the Form_Load event is executed.
Code:
Imports System.Data.Sql
Public Class frmMain
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dt As Data.DataTable = Nothing, dr As Data.DataRow = Nothing
Try
'get sql server instances in to DataTable object
dt = Sql.SqlDataSourceEnumerator.Instance.GetDataSources()
'load data in to ComboBox
For Each dr In dt.Rows
Me.CmbSQLInstance.Items.Add(dr.Item(0).ToString)
Next
'load data in to DataGridView
Me.DGVSQLInstances.DataSource = dt
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
Finally
'clean up
dr = Nothing
dt = Nothing
End Try
End Sub
End Class
I found this code at How to enum SQL Server instances in network
Here is the form when the project is executed from within the IDE:
This is as simple as it gets. So why doesn't it show the name of my PC(MRM-WINX-002) as containing an instance of SQL Server?
MRM256
Continue reading...
To this end I created a barebones application that just lists the instances of SQL Server.
I have an application that contains one form with a combo box control and a DataGridView control.
The application searches for SQL Server instances when the Form_Load event is executed.
Code:
Imports System.Data.Sql
Public Class frmMain
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dt As Data.DataTable = Nothing, dr As Data.DataRow = Nothing
Try
'get sql server instances in to DataTable object
dt = Sql.SqlDataSourceEnumerator.Instance.GetDataSources()
'load data in to ComboBox
For Each dr In dt.Rows
Me.CmbSQLInstance.Items.Add(dr.Item(0).ToString)
Next
'load data in to DataGridView
Me.DGVSQLInstances.DataSource = dt
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error!")
Finally
'clean up
dr = Nothing
dt = Nothing
End Try
End Sub
End Class
I found this code at How to enum SQL Server instances in network
Here is the form when the project is executed from within the IDE:
This is as simple as it gets. So why doesn't it show the name of my PC(MRM-WINX-002) as containing an instance of SQL Server?
MRM256
Continue reading...