Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have added SQL Server express edition as a prerequisite so it automatically installs on computer.
But at the time of installing it set SQL authentication mode as windows and TCP/IP settings as disabled.

Now suggest me how do i change the above settings programatically after SQL installed on computer.
Posted
Updated 9-Jan-12 20:45pm
v2

SQL Server Management Objects (SMO) is a collection of objects that are designed for programming all aspects of managing Microsoft SQL Server. Reference at: http://msdn.microsoft.com/en-us/library/ms162169.aspx[^]
 
Share this answer
 
Comments
sahabiswarup 10-Jan-12 2:50am    
can you please explain it.
C#
private void button1_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = Application.StartupPath.Trim() + @"\SqlServer2005 Express\SQLEXPR.EXE";
            //-q[n|b|r|f]   Sets user interface (UI) level:
            //n = no UI
            //b = basic UI (progress only, no prompts)
            //r = reduced UI (dialog at the end of installation)
            //f = full UI
            psi.Arguments = "/qb username=\"sa\" companyname=\"Rumtek\" addlocal=ALL  disablenetworkprotocols=\"0\" instancename=\"SQLExpress\" SECURITYMODE=\"SQL\" SAPWD=\"lock\"";
            p.StartInfo = psi;
            p.Start();
        }

private void button2_Click(object sender, EventArgs e)
        {
            //Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IPAll", "TcpPort", "1433");
            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\SuperSocketNetLib\Tcp\IPAll", "TcpPort", "1433");
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = Application.StartupPath.Trim() + @"\command\cmd.exe";
            psi.Arguments = "NET STOP MSSQL$SQLExpress";
            p.StartInfo = psi;
            p.Start();
            Process p1 = new Process();
            ProcessStartInfo psi1 = new ProcessStartInfo();
            psi1.FileName = Application.StartupPath.Trim() + @"\command\cmd.exe";
            psi1.Arguments = "NET START MSSQL$SQLExpress";
            p1.StartInfo = psi1;
            p1.Start();
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900