Executing script in sql server using c# code
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...