hi experts..
I need to execute a script in sql server using c#.i have used this code
string sqlConnectionString = @"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=FinAccounts;Data Source=computer3\\SQLEXPRESS";
FileInfo file = new FileInfo(@"E:\SQLQuery3.sql");
string script = file.OpenText().ReadToEnd();
MessageBox.Show(script.ToString());
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
file.OpenText().Close();
but an error "Failed to connect to the server" appears...what is the problem.
what should i change in the code?..please replay...
Executing script in sql server using c# code
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Manikavelu VelayuthamRank #413 · 6K reputationPosted Oct 12, 2010, 1:35 AM EDT
Resmy Ravi74 reputationPosted Oct 12, 2010, 1:48 AM EDT
but how can i sove that problem? please replay
Manikavelu VelayuthamRank #413 · 6K reputationPosted Oct 12, 2010, 2:09 AM EDT
http://codeeleven.blogspot.com/2007/12/setting-up-sqlexpress-database-for-use.html