locked
Enumerate Instances (Previos Post/Articles Not Helping) RRS feed

  • Question

  • Hello,

    I know this question has been asked and I've read the post, and blogs etc. but I am still not getting the expected results OR not understanding what I should be getting. When using (VS2010 .NET 4.0  SMO 9 & 10 behave same)  SmoApplication.EnumAvailableSqlServers(); or SqlDataSourceEnumerator.Instance.GetDataSources(); I am only getting the main SQL Server instance and other instances on that box are not displaying.

    For example I have a test box right next to me with 2 SQL instances. ODSTest an ODSQA. When enumerating I get ODSTest as that is the default instance but the second instance ODSQA never shows and I can't figure out why. Calling EnumAvailableServers("ServerName"); does NOT reveal the ODSQA instance either just the original default of ODSTest. I have read and understand that a broadcast packet is sent out and there may be a delay in response. However it is a little odd how I can get 323 servers across our enterprise to respond but the second instances (for the machines that have them) never show up. Further checking the behavior with SSMS and it works the same???!! Msoft when enumerating across the network doesn't show the instances either so what am I not understanding?

    TIA

    JB

    Thursday, January 27, 2011 11:10 AM

Answers

  • Hi,

    How do you enumerate instances? Could you please post the snippets of code?

    I performed a test by using the EnumAvailableSqlServers method, when we specify true as the parameter of the EnumAvailableSqlServers method, we can enumerate instances (default instance and named instance) on my local machine. Please see:

    DataTable dt = SmoApplication.EnumAvailableSqlServers(true);
    foreach (DataRow dr in dt.Rows)
    {
      Console.WriteLine(dr["Name"]); 
      Console.WriteLine(dr["IsLocal"]);
    }
    Console.ReadLine();
    
    
    

    When we specify false as the parameter of the EnumAvailableSqlServers method, we can enumerate instances across the network.

    Besides, I also performed a test by using the SqlDataSourceEnumerator method, we can enumerate active servers on the network, please see:
    http://blogs.msdn.com/b/sushilc/archive/2004/10/14/242395.aspx

    For more information, please see:
    SmoApplication.EnumAvailableSqlServers Method
    http://msdn.microsoft.com/en-us/library/ms210425.aspx
    Enumerating Instances of SQL Server
    http://msdn.microsoft.com/en-us/library/a6t1z9x2.aspx


    Thanks,
    Ai-Hua Qiu


    Ai-hua Qiu[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Ai-hua Qiu Friday, February 4, 2011 6:45 AM
    Friday, January 28, 2011 5:10 AM