Поделиться через


SMO Sample: Enable TCP/IP Server protocol of SQL Server 2005

Purpose of sample: Enable the TCP/IP server protocol.

 

This sample shows you how to change a server protocol setting. This sample assumes you have SQL Express installed. You need to change the instance name to match the instance name you have installed.

 

ManagedComputer mc = new ManagedComputer();

mc.ServerInstances[

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

Comments

  • Anonymous
    September 13, 2007
    Hi, I tried this code, it doesn't throw any error. But still the SQL server Configuration manager shows, disabled. Could you help! Best Regards, DHAKCHINA MOORTHY.C

  • Anonymous
    March 28, 2008
    I too have been trying this.  But TCP/IP remains disabled. Trying different wrong server names crashes my code... which implies I am using the right server name. Don't know why it isn't working.

  • Anonymous
    March 28, 2008
    Wait, I think I figured it out. Calling the Alter method on ServiceProtocol object after making the change worked for me. Wmi.ManagedComputer mc = new Wmi.ManagedComputer(); Wmi.ServerProtocol sp = mc.ServerInstances["SQLEXPRESS"].ServerProtocols["Tcp"].IsEnabled = true; sp.Alter();

  • Anonymous
    March 28, 2008
    The comment has been removed