Friday, August 10, 2012

Cannot open database “ASPState” requested by the login. The login failed. Login failed for user ‘sa’


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot open database “ASPState” requested by the login. The login failed.
Login failed for user ‘sa’.
Prompted with the infamous error as shown above. If you’re facing the same issue as mine when trying to run a web application connecting to MSSQL 2008 R2, then you might want to try:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S DB_SERVER_NAME -E -ssadd -sstype p
P/S: browse to the designated folder before executing the program aspnet_regsql.exe
Hope it helps.
Update: IF you hit an error when running the command above like below:
Start adding session state.
…………………..
An error has occurred. Details of the exception:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
Unable to connect to SQL Server database.
Solution: Proceed to SQL Configuration Manager and browse to SQL Server Network Configuration -> Protocols for MSSQLSERVER then enable Named Pipes. Restart the SQL Server and retry executing the command.
It worked!!!!!

No comments:

Post a Comment