Tuesday, February 22, 2011

Fixing issue "Cannot connect to the configuration database"

One day on my Dev machine I received the following error while browsing my site. 


The I searched on the Google and find out this Microsoft KB article and followed each steps. Though it was written for WSS 2.0 but it's working fine for WSS 3.0 and MOSS. But following those steps does not helped much. 
While working on SQL Database, I found a wired thing that is SharePoint_Config Db is marked as 'Suspect'.
  


After further research, I found this blog to use the DB script to restore it back to the original condition.


EXEC sp_resetstatus 'DBname'
ALTER DATABASE DBname SET EMERGENCY
DBCC checkdb('DBname')
ALTER DATABASE DBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('DBname', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE DBname SET MULTI_USER



Final Issue: At the time of using this script I am getting sql error. Incorrect syntax near '-'. This error causing by the illegal characters in the DB name. As SharePoint adds GUID in the title of SharePoint config database.


We need to use a [bracket] for handling such issues. This Microsoft site got details about it.
use [SharePoint_AdminContent_d610f804-ebc5-4480-91a8-1f0a53de078a]



No comments: