Cannot open database using ADO.Net

Posted on 2011-11-01
Last Modified: 2012-05-12
I am trying to run the following code.  I am get an SqlException when executing through the theConnection.Open()

                ConnectionStringSettings theConnectionString = ConfigurationManager.ConnectionStrings["TK70561.Properties.Settings.VideoGameStoreDB"];

                SqlConnection theConnection = new SqlConnection(theConnectionString.ConnectionString);
                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.
Question by:tommym121
    LVL 43

    Accepted Solution

    theConnectionString = "Data Source=COMPUTER1\SQLTEST;Initial Catalog=VidoeGames;Integrated Security=SSPI";

    Is that correct?  (Because you write about a differently named database in the body of the question.)
    LVL 22

    Expert Comment

    try the full path  

    Author Closing Comment

    Thanks.  It is a typo.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now