You must Sign In to post a response.
  • Category: .NET

    How to get all the datasource name in a network or local machine

    Dim SqlEnumerator As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance
    Dim dt As DataTable = SqlEnumerator.GetDataSources
    If dt.Rows.Count > 0 Then
    cbodatasource.DataSource = dt
    End If


    Dim app As New SQLDMO.Application()
    Dim names As SQLDMO.NameList = app.ListAvailableSQLServers()
    If names.Count > 0 Then
    For Each name As String In names
    cbodatasource.SelectedIndex = -1
    End If

    I have tired this two method, but its not working.
    not able to fetch the datasource name in my combobox.

  • #587209
    hey sandip i think these two function will help you
    so try this

    DataTable dataTable = new DataTable();
    public void GetSQLInstances()
    System.Data.Sql.SqlDataSourceEnumerator instance = System.Data.Sql.SqlDataSourceEnumerator.Instance;
    dataTable = instance.GetDataSources();

    if (dataTable.Rows.Count > 0)
    private void InstancesInformation()
    string strList = "";
    foreach (DataRow row in dataTable.Rows)
    datasources.Items.Add(row[0] + "/" + row[1]);

    hope this will help you

  • #587237
    Thank Jignesh for your post, but still its not working.
    Presently m working on a machine which is not connected in lan but hav sql install in it.
    it must show this local datasource atleast, but its not showing.

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.