Sunday, October 14, 2012

Cannot open database 'WSS_Content' Requested by the login. The login failed.

In a SharePoint 2007 environment, All of a sudden, all custom applications which uses server object model, started failing with an error: Cannot open Database WSS_Content_SharePoint_DB requested by the login. The login Failed. Login failed for user <domain\user_account>

Cannot open Database Database_Name requested by the login. The login Failed. Login failed for user <domain\user_account>
Root cause of the Problem was:There was an old unused content database attached with a site collection. Since the particular site collection was no longer needed, SharePoint Administrator just deleted the database during a maintenance window.

But SharePoint configuration was still referring the database and trying to connect! This error got logged multiple times in event log also. So the right sequence would be:
  • Delete the content database from SharePoint first (stsadm -o deletecontentdb or using Central Administration) 
  • Then delete the database from SQL Server.stsadm -o deletecontentdb
This error may appear when there is a permission issue and can be resolved by either granting access to the service account or changing the SharePoint Timer service's identity to the account which has enough privileges on the databases, which is described here: Event ID 3351: SQL database login failed

Cannot open database 'db_name' Requested by the login.- Error in SharePoint 2013:
Same issue happened in SharePoint 201, with Event ID: 3760

SQL Database "db_name" on SQL Server instance "sql_instance_name" not found. Additional error information from SQL Server is included below.

  Cannot open database “db_name” requested by the login. The login failed. Login failed for user ‘domain\login’

Solution: Remove the deleted Database reference from SharePoint using PowerShell:
Get-SPDatabase | where {$ -eq 'db_name'} | foreach {$_.Delete()};

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

1 comment :

  1. Thanks for your post. It helped me in fixing my issue.


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...