Link to home
Start Free TrialLog in
Avatar of tommym121
tommym121Flag for Canada

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.ConnectionStrings["TK70561.Properties.Settings.VideoGameStoreDB"];

                SqlConnection theConnection = new SqlConnection(theConnectionString.ConnectionString);
                Console.WriteLine(theConnectionString.ToString());
                theConnection.Open();
                if (theConnection.State == System.Data.ConnectionState.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;Initial Catalog=VidoeGames;Integrated 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.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try the full path  
EX
Data Source=C:\PROGRAM FILES\SQL SERVE\SQLTEST
Avatar of tommym121

ASKER

Thanks.  It is a typo.