Cannot open database requested by the login. The login failed. Login failed for user

  • hi!

    i have create a vizual c# program linq to sql ..when i whont to open the databse from vizual i have this error ...

    Cannot open database requested by the login. The login failed. Login failed for user

    please can someone help me ??

  • Pretty sparse on details but we will see what we can do.

    Can you connect to the database is SSMS with the same credentials you are using from your application? Double check username and password as a place to start.

    Does the user have access to the database you are trying to connect to?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • when I open the database from sql it not open to visual c# and vice versa

    and when i do the add student on the program, the student is adde to the datagred..but not added on the database . i use windows authentication.

    sometime seid that the database is used by other program πŸ™

  • So you can only have 1 open connection at a time? Are you using Access?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Here is few troubleshooting I would do as starting point…

    1)Make sure in the C# code connection string, you pointing to correct database and using the correct credential.

    2) As Sean suggested go SSMS and try use the credentials you are trying to use, if it fails connect as admin and see if the user has credentials and mapped to the correct database

    Hope it helps.

  • i have to create a desktop program ,and im usin vizual c# 2010 and sql server 2008 both expres edition .

    now i create the code and the connection ...bug the program doesen add the student on the database only on the datagrid

    if i open the database first on sql server i cant open it on the vizual C # ..and the error is : Cannot open database requested by the login. The login failed. Login failed for user

    but if i open the database first on vizua c i cant open then on the sql server ..and the error is : The database is not accessible (ObjectExplorer)

  • Make sure SQL server is running, the database exists and is online …….

    Also in Visual studio when you added the data source connection did you run a test connection at the end of the wizard? If not try to re-create your connection through the IDE and test as well.

  • at first time i run the program as administrator and the test connection go OK

    but when i do the test now i got a error

    can i send you the program and see it?? pls i really have to do this

  • alban_ml (11/15/2011)


    at first time i run the program as administrator and the test connection go OK

    but when i do the test now i got a error

    can i send you the program and see it?? pls i really have to do this

    I guess you are not saving these credentials in Connection String. It’s just a logical error in your .Net Connection String. Focus only on it.

  • <connectionStrings>

    <add name="Business.Properties.Settings.SchooldbConnectionString"

    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Schooldb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

    providerName="System.Data.SqlClient" />

    </connectionStrings>

    this is the connecion string...i dont know were is the proble πŸ™

  • alban_ml (11/16/2011)


    <connectionStrings>

    <add name="Business.Properties.Settings.SchooldbConnectionString"

    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Schooldb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

    providerName="System.Data.SqlClient" />

    </connectionStrings>

    this is the connecion string...i dont know were is the proble πŸ™

    Connection strings for SQL Server 2005

    http://connectionstrings.com/sql-server-2005

  • http://answerforu.com/2011/09/26/cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-%e2%80%98usename/[/url]

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply