Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;
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
Posted
Comments
[no name] 16-May-13 5:36am    
https://www.google.com/search?q=A+network-related+or+instance-specific+error+occurred+while+establishing+a+connection+to+SQL+Server&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
sencsk 16-May-13 6:04am    
shell(ur local path)..

1 solution

private void InstallSQlServer()
       {
           ProcessStartInfo startinfo = new ProcessStartInfo();
           startinfo.FileName = "cmd.exe";
           startinfo.RedirectStandardInput = true;
           startinfo.RedirectStandardOutput = true;
           startinfo.UseShellExecute = false;
           // startinfo.CreateNoWindow = true;
           myprocess.StartInfo = startinfo;
           myprocess.Start();
           System.IO.StreamReader SR = myprocess.StandardOutput;
           System.IO.StreamWriter SW = myprocess.StandardInput;
           SW.WriteLine(@"""C:\Users\Administrator\Desktop\SQL Express UnAttended Installation\SQLEXPRADV_x86_ENU.exe"" /ConfigurationFile= ""C:\Users\Administrator\Desktop\SQL Express UnAttended Installation\Configuration.ini"" /IACCEPTSQLSERVERLICENSETERMS /Q /SAPWD=""exp2oo8@r2"" ");
           myprocess.WaitForExit();
           MessageBox.Show(SR.ReadToEnd());
           SW.WriteLine("exit");
           SW.Flush();
           SR.Close();


       }
 
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