How to Install SQL Server Express R2 2008 Programatically – CodeProject

I have SQL Server Express R2 2008 setup in my local hard disk, now i want run the setup using c#.net.

string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + “\\SQLEXPR.exe”;
Process psql = new Process();
psql.StartInfo.FileName = path;
psql.StartInfo.Arguments = @”/qs /Action=Install /Hideconsole /IAcceptSQLServerLicenseTerms=””True”” /Features=SQL,Tools /INSTANCENAME = \””SQLEXPRESS\””INSTALLSQLDIR = \””c:\\Program Files\\Microsoft SQL Server\””INSTALLSQLSHAREDDIR = \””c:\\Program Files\\Microsoft SQL Server\””INSTALLSQLDATADIR = \””C:\\Program Files\\Microsoft SQL Server\””ADDLOCAL = \””All \””SQLAUTOSTART = 1 SQLBROWSERAUTOSTART = 1 SQLBROWSERACCOUNT = \””NT AUTHORITY\\SYSTEM\””SQLACCOUNT = \””NT AUTHORITY\\NETWORK SERVICE\””SECURITYMODE = SQL SAPWD = \””\””SQLCOLLATION = \””SQL_Latin1_General_Cp1_CS_AS\””ERRORREPORTING = 1 ENABLERANU DISABLENETWORKPROTOCOLS = 0 = 0″””;

psql.StartInfo.CreateNoWindow = true;

C#

psql.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
psql.Start();

  psql.WaitForExit();

i used the above code it’s installed, but i’m trying to open the connection it’s throwing the Error

‘A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)’

Please can any one suggest me

Thanks in Advance

Hi Friends,I have SQL Server Express R2 2008 setup in my local hard disk, now i want run the setup using c#.net.string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + “\\SQLEXPR.exe”;Process psql = new Process();psql.StartInfo.FileName = path;psql.StartInfo.Arguments = @”/qs /Action=Install /Hideconsole /IAcceptSQLServerLicenseTerms=””True”” /Features=SQL,Tools /INSTANCENAME = \””SQLEXPRESS\””INSTALLSQLDIR = \””c:\\Program Files\\Microsoft SQL Server\””INSTALLSQLSHAREDDIR = \””c:\\Program Files\\Microsoft SQL Server\””INSTALLSQLDATADIR = \””C:\\Program Files\\Microsoft SQL Server\””ADDLOCAL = \””All \””SQLAUTOSTART = 1 SQLBROWSERAUTOSTART = 1 SQLBROWSERACCOUNT = \””NT AUTHORITY\\SYSTEM\””SQLACCOUNT = \””NT AUTHORITY\\NETWORK SERVICE\””SECURITYMODE = SQL SAPWD = \””\””SQLCOLLATION = \””SQL_Latin1_General_Cp1_CS_AS\””ERRORREPORTING = 1 ENABLERANU DISABLENETWORKPROTOCOLS = 0 = 0″””;psql.StartInfo.CreateNoWindow = true;i used the above code it’s installed, but i’m trying to open the connection it’s throwing the Error’A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)’Please can any one suggest meThanks in Advance