SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = @".\SQLEXPRESS";
builder.InitialCatalog = "database";
builder.IntegratedSecurity = true;
SqlConnection linkToDB = new SqlConnection(builder.ConnectionString);
linkToDB.Open();
using (linkToDB)
{
commandWrapper.Connection = linkToDB;
commandWrapper.ExecuteNonQuery();
}
When I execute the code I receive the following error:
Cannot open database "database" requested by the login. The login failed.
Login failed for user 'computername\username'.
Line 151:
Line 152: SqlConnection linkToDB = new SqlConnection(builder.ConnectionString);
Line 153: linkToDB.Open();
Line 154:
Line 155: using (linkToDB)
The error is at Line 153 ->
How can I open the connection to the database? Any ideas?

New Topic/Question
Reply



MultiQuote






|