SessionState web.config SQL 2008 custom database

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?
tarasbredelAsked:
Who is Participating?
 
tarasbredelAuthor Commented:
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
 
wolfman007Commented:
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
 
tarasbredelAuthor Commented:
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
 
wolfman007Commented:
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
 
tarasbredelAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.