?
Solved

SessionState web.config SQL 2008 custom database

Posted on 2009-02-24
5
Medium Priority
?
1,373 Views
Last Modified: 2012-05-06
I'm trying to use SQL 2008 for sessionstate, but keep getting the Login Failed exception...
[SqlException (0x80131904): Cannot open database "bSession-sd" requested by the login. The login failed. Login failed for user '********'.]

I've setup following web.config...
    <sessionState
                mode="SQLServer"
                sqlConnectionString="data source=SQL01-NODE1; Initial Catalog=bSessions-sd; user id=********; password=********; Failover Partner=SQL01-NODE2;"
                cookieless="false" allowCustomSqlDatabase="true"
                timeout="20" />

If I try connecting through Studion Management, with the same credentials, I'm granted full access.
The user account on the database is db_owner

What could possibly be the issue here?
0
Comment
Question by:tarasbredel
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:wolfman007
ID: 23722517
Try making sure that the default database for the user account that you are connecting with is the database that the user has permission to access.

Also how did you set up the session database did you use ASPNET_REGSQL.EXE, see the following website

http://www.developer.com/db/article.php/3595766
0
 

Author Comment

by:tarasbredel
ID: 23725799
Currently the user has master set as default database.
Our ISP installed the session database using REGSQL in persisten mode.
We only have one user for both the session database and the actualt database, is that a problem? Does it have to be a distinct user for each?
0
 
LVL 14

Expert Comment

by:wolfman007
ID: 23731937
Using a distinct user for each would be better from a security point of view, but it is not essential.

I think your problem is that your user account does not have permission to access its default database.

When a user first connects to SQL Server it connects to its default database, and since your user is trying connect to the master database without permissions to access the master database you are getting the error.

Try changing the user's default database to bSession-sd
0
 

Author Comment

by:tarasbredel
ID: 23732050
Might be, though, I have no issues accessing my actual database with that user account (neither from my web app or from Studio Management).
it is only the session database that is bugging from the app
0
 

Accepted Solution

by:
tarasbredel earned 0 total points
ID: 23784188
It seems that the ISP had installed the session database wrong.
He had used the -sstype p switch, created the ASPState database, and then renamed it to bSession_sd

The problem is that you cannot use the -sstype p and -d dbname switches together. It has to be -sstype c and -d dbname together.
But then the session database is not persistent.
Then again that is nt a problem, since we are using mirrored SQL.

Btw. The login has master set as default since it cannot be altered on the failover partner unless you flip the mirror first.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question