SMO to Modify Server Protocol

Hello,

I am trying to Enable TCP/IP server protocol on SQL 2005. Under SMO I see Microsoft.SqlServer.Management.Smo.Wmi.ServerProtocol

But I am not sure how to get to that information.

Anyone have any ideas on how to do this

Thanks in advanced




Answer this question

SMO to Modify Server Protocol

  • gmork

    This should work (note the instance name is different):
    ManagedComputer mc = new ManagedComputer();

    mc.ServerInstances["SQLEXPRESS"].ServerProtocols["Tcp"].IsEnabled = true;



  • Interesting

    ClientProtocol.IsEnabled
  • llebron

    This is because you've change only local protocol object state, not actual service protocol setting. To do this, you should call Alter method of ServerProtocol class after property change

    oComputer.ServerInstances("SQLEXPRESS").ServerProtocols("TCP").IsEnabled = True

    oComputer.ServerInstances("SQLEXPRESS").ServerProtocols("TCP").Alter()

    WBR, Evergray
    --
    Words mean nothing...


  • MichaelLaw

    Evergray you are a genius. I had not noticed the alter command in the SDK.

    Thanks

    Grey



  • Jim Selinsky

    That is what I thought but unless I am doing something wrong that does not appear to work.

    Dim oComputer As New ManagedComputer(sServer)

    Debug.Print(oComputer.ServerInstances("SQLEXPRESS").ServerProtocols("TCP").IsEnabled.ToString)

    'Result is False

    oComputer.ServerInstances("SQLEXPRESS").ServerProtocols("TCP").IsEnabled = True

    'OK now stop and start service for the changes to take effect

    oComputer.Services("MSSQL$SQLEXPRESS").Stop()

    oComputer.Services("MSSQL$SQLEXPRESS").Start()

    'Now clear the managed computer so we can ask if the protocol is

    'enabled at this point.

    oComputer = Nothing

    oComputer = New ManagedComputer(sServer)

    Debug.Print(oComputer.ServerInstances("SQLEXPRESS").ServerProtocols("TCP").IsEnabled.ToString)

    'Result is False

    I confirmed this through the SQL server configuration manager. The status of the TCP protocol never changes

    I am logged into the local box as a local administrator and as a Domain administrator

    Can someone duplicate this problem



  • SMO to Modify Server Protocol