Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 R2 Express error: Cannot open database "PersonnelPro" requested by the login. The login failed

I am using SQL Server 2008 R2 Express and the "SQL Server and Windows Authentication" mode in my database. I can open the database using Enterprise Manager, but when I run my aspx application, I get:

Cannot open database "PersonnelPro" requested by the login. The login failed.

My web.config connection string is:

<add name="dbString" 
     connectionString="Provider=sqloledb;Data Source=AREA51\SQLEXPRESS;Initial Catalog=PersonnelPro;User Id= ****;Password= ****" />`   

I searched the web and SO, but could not find a solution. Any ideas what would be causing this issue?

Update:
Looking into SQL log files ("C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Log"), I find this:

2012-12-21 05:58:00.97 Logon       Error: 18456, Severity: 14, State: 38.
2012-12-21 05:58:00.97 Logon       Login failed for user 'PersonnelPro'. Reason: Failed to open the explicitly specified database. [CLIENT: <named pipe>]

This web application is by a 3rd party company. So technically, I only need to configure my web.config file and it should work.

like image 712
DNR Avatar asked Dec 21 '12 01:12

DNR


1 Answers

Remove the space after the '=' sign for User Id and Password. I think it is being interpreted as part of the value.

Update:

The new error message you posted (Failed to open the explicitly specified database.) can mean one of two things:

  • The DB with that name doesn't exist or is misspelled.
  • The user you are trying to log in with does not have access to the DB. You can check this by running exec sp_helpuser 'username' in the DB.
like image 139
saarp Avatar answered Nov 12 '22 12:11

saarp