SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Cannot open database “” requested by the login. T
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hossein
Starting Member

Iran
3 Posts

Posted - 02/25/2013 :  14:58:33  Show Profile  Reply with Quote
Hello I am trying to use SQL Authentication to connect to a database .I am having extreme difficulties and my searches so far couldn't help me solve the problem.

I Enabled the SQL Authentication through SQL SERVER MANAGEMENT STUDIO and enabled sa and set a simple password for it.(under .\sqlexpress - i mean my server-name is ).
Now I can Successfully log in to the database by sa and its password from SQL SERVER MANAGEMENT STUDIO but when i try to do so from my application it fails with this error message :
quote:
Cannot open database "dbNegin" requested by the login. The login failed. Login failed for user 'sa'.

I need to say that i changed the database owner to sa as well, yet i get this error!!
How can i solve this now? :(
By the way this is the connection string used in my application to connect to the database :
quote:
string sqlconstring = @"Data Source=.\sqlexpress;User ID=sa;Password=123456;Initial Catalog=dbNegin";


My data base is attached by the way (its located in the address below )
quote:

" D:\TestDb\Debug\dbNegin.mdf"



And this is the latest error log:
quote:
2013-02-25 21:51:18.59 spid51 Attempting to load library 'xpstar.dll' into memory. This is an informational message only. No user action is required.
2013-02-25 21:51:18.59 spid51 Using 'xpstar.dll' version '2007.100.1600' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.
2013-02-25 21:51:20.80 spid51 Starting up database 'C:\USERS\FRIEND\DESKTOP\RELEASE\DBNEGIN.MDF'.
2013-02-25 21:51:21.33 spid51 Starting up database 'mytestdb'.
2013-02-25 21:51:21.60 spid51 Starting up database 'C:\USERS\FRIEND\DESKTOP\RELEASE\DBNEGIN.MDF'.
2013-02-25 21:51:35.60 Logon Error: 18456, Severity: 14, State: 38.
2013-02-25 21:51:35.60 Logon Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]
2013-02-25 22:11:00.79 Server Server resumed execution after being idle 246 seconds: user activity awakened the server. This is an informational message only. No user action is required.
2013-02-25 22:11:00.97 spid51 Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
2013-02-25 22:11:01.04 spid51 Using 'xplog70.dll' version '2007.100.1600' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
2013-02-25 22:57:29.06 spid53 Starting up database 'C:\USERS\FRIEND\DESKTOP\RELEASE\DBNEGIN.MDF'.
2013-02-25 22:58:40.51 Logon Error: 18456, Severity: 14, State: 38.
2013-02-25 22:58:40.51 Logon Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]
2013-02-25 23:07:09.86 Logon Error: 18456, Severity: 14, State: 38.
2013-02-25 23:07:09.86 Logon Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]
2013-02-25 23:07:16.37 Logon Error: 18456, Severity: 14, State: 38.
2013-02-25 23:07:16.37 Logon Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]


Edited by - Hossein on 02/25/2013 15:00:24

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2076 Posts

Posted - 02/26/2013 :  01:54:20  Show Profile  Visit jackv's Homepage  Reply with Quote
can you confirm the default database set for the logon and the explicit catalog defined in the connection string are available and the logon account has access rights to those 2 databases?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

Hossein
Starting Member

Iran
3 Posts

Posted - 02/26/2013 :  02:34:30  Show Profile  Reply with Quote
quote:
Originally posted by jackv

can you confirm the default database set for the logon and the explicit catalog defined in the connection string are available and the logon account has access rights to those 2 databases?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com


Thank you very much for your answer. The problem was all you have just mentioned :)
The following thread solved my problem and here is the link for further references:
quote:
http://www.sqlservercentral.com/Forums/Topic1423758-391-1.aspx?Update=1
Go to Top of Page

sebantom1979
Starting Member

6 Posts

Posted - 03/05/2013 :  07:45:53  Show Profile  Reply with Quote
http://answerforu.com/2011/09/26/cannot-open-database-requested-by-the-login-the-login-failed-login-failed-for-user-%e2%80%98usename/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000