tommym121
asked on
Cannot open database using ADO.Net
I am trying to run the following code. I am get an SqlException when executing through the theConnection.Open()
try
{
ConnectionStringSettings theConnectionString = ConfigurationManager.Conne ctionStrin gs["TK7056 1.Properti es.Setting s.VideoGam eStoreDB"] ;
SqlConnection theConnection = new SqlConnection(theConnectio nString.Co nnectionSt ring);
Console.WriteLine(theConne ctionStrin g.ToString ());
theConnection.Open();
if (theConnection.State == System.Data.ConnectionStat e.Open)
returnMessage = "Database Connection is Open";
}
catch (SqlException sqlexception)
{
returnMessage = sqlexception.Message;
}
catch (Exception exception)
{
returnMessage = exception.Message;
}
My connection sting is as follows:
theConnectionString = "Data Source=COMPUTER1\SQLTEST;I nitial Catalog=VidoeGames;Integra ted Security=SSPI";
This is the message from the sqlException:
returnMessage "Cannot open database \"VidoeGames\" requested by the login. The login failed.\r\nLogin failed for user 'Computer1\\user1'." string
I am running all on the same computer. I can login into SQL Server Management Studio using Computer1\user1. The VideoGames Database is owned by Computer1\\user1.
Can anyone suggest what I need to check to resolve such problem.
try
{
ConnectionStringSettings theConnectionString = ConfigurationManager.Conne
SqlConnection theConnection = new SqlConnection(theConnectio
Console.WriteLine(theConne
theConnection.Open();
if (theConnection.State == System.Data.ConnectionStat
returnMessage = "Database Connection is Open";
}
catch (SqlException sqlexception)
{
returnMessage = sqlexception.Message;
}
catch (Exception exception)
{
returnMessage = exception.Message;
}
My connection sting is as follows:
theConnectionString = "Data Source=COMPUTER1\SQLTEST;I
This is the message from the sqlException:
returnMessage "Cannot open database \"VidoeGames\" requested by the login. The login failed.\r\nLogin failed for user 'Computer1\\user1'." string
I am running all on the same computer. I can login into SQL Server Management Studio using Computer1\user1. The VideoGames Database is owned by Computer1\\user1.
Can anyone suggest what I need to check to resolve such problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It is a typo.
EX
Data Source=C:\PROGRAM FILES\SQL SERVE\SQLTEST