Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 793933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:14:05+00:00 2026-05-14T22:14:05+00:00

I am trying to use SMO (VS 2010, SQL Server 2008) to connect to

  • 0

I am trying to use SMO (VS 2010, SQL Server 2008) to connect to SQL Server and view the server protocol configuration. I can connect and list the Services and ClientProtocols as well as the account MSSQLSERVER service is running under. However, the ServerInstances collection is empty. The only instance on the target server is the default (MSSQLSERVER), shouldn’t that be in the collection? How can I get an instance of it so I can inspect the ServerProtocols collection? Here’s the code I’m using:

    class Program
{
    static void Main(string[] args)
    {
        //machine hosting installed sql server instance
        ManagedComputer host = new ManagedComputer("fully-qualified.host.name");


        if (host.ServerInstances.Count != 0)
        {
            //why is this 0? Is it because only the DEFAULT instance exists?
            Console.WriteLine("/////////////// INSTANCES ////////////////");
            foreach (ServerInstance inst in host.ServerInstances)
            {
                Console.WriteLine(inst.Name);
            }
        }

        Console.WriteLine("/////////////// SERVICES ////////////////");
        // enumerate sql services (looking for MSSSQLSERVER)
        foreach (Service svc in host.Services)
        {
            Console.WriteLine(svc.Name);
        }

        Console.WriteLine("/////////////// DETAILS ////////////////");

        // get name of MSSQLSERVER instance from user (pick from list above)
        Service mssqlserver = host.Services["MSSQLSERVER"];

        // print service account: .\{account} == "local account", "LocalSystem", "NetworkService", {domain}\{account} == "domain account"
        Console.WriteLine("Service Account: {0}", mssqlserver.ServiceAccount);

        // get client protocols
        foreach (ClientProtocol cp in host.ClientProtocols)
        {
            Console.WriteLine("{0} {1} ({2})", cp.Order, cp.DisplayName, cp.IsEnabled ? "Enabled" : "Disabled");
        }

    }
}

I’ve also tried:

            Urn u = new Urn("ManagedComputer[@Name='fully-qualified.host.name']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']");
        ServerProtocol tcp = host.GetSmoObject(u) as ServerProtocol;
        if (tcp != null)
        {
            Console.WriteLine("{0}", tcp.DisplayName);
        }

But I get an error message stating: “child expressions are not supported.” Any ideas what’s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:14:06+00:00Added an answer on May 14, 2026 at 10:14 pm

    So I never found the answer to this, but I came up with a workaround.

                ManagedComputer host = new ManagedComputer(hostName);
    
            Server server = new Server();
            Console.WriteLine("TcpEnabled: {0}", server.TcpEnabled);
    

    This gets me what I need, I would prefer to be able to enumerate the ServerProtocols, but this will allow me to verify the very minimum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use SMO in visual studio 2010 express. Every time I
I am trying to restore a backup file to SQL Server 2008. I am
I am trying use the new server side plug-in feature for TFS 2010. (I
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I am trying to connect to a remote sql database and simply run the
What's the best method to check if SQL server exists or not? I'm trying
I'm a little confused here, I am trying use a partial view in a
I am trying to use SMO in a Windows Forms application to restore a
I'm trying to create a table using SMO, and further use the SqlBulkCopy object
I am trying use Accrev plugin for visual studio 2010. I am not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.