Cannot open database requested in login 'ASPState'. Login fails. Login failed for user 'sa'.

From: Greg Dunn (MyLists_at_gregdunn.com)
Date: 05/16/03


Date: Thu, 15 May 2003 15:40:59 -0700


While experimenting with different options for saving session state in a
Visual Studio app, I got round to the option for storing the state in SQL
Server. The following is the complete web.config file for the sample app I'm
running (password changed):

  <configuration>
     <appSettings>
        <add key="connectString"
value="server=localhost;database=pubs;uid=sa;pwd=whatever" />
     </appSettings>

     <system.web>
        <compilation defaultLanguage="C#" debug="true">
        </compilation>
        <sessionState mode="SQLServer"
sqlConnectionString="server=localhost;uid=sa;pwd=whatever" />
     </system.web>

  </configuration>

That results in the error message shown in the subject, even though 'sa' is
a defined login on the database, with the specified password, System Admin
permissions, and owner access to all databases. In the absence of the
sessionState statement (so the app runs with the default in-proc session
state), the app works fine

Q: What is causing the login failure?

I am appending the complete error message below in case it is needed.

-- 
Greg Dunn
Server Error in '/Congo' Application.
----------------------------------------------------------------------------
----
Cannot open database requested in login 'ASPState'. Login fails. 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
requested in login 'ASPState'. Login fails. Login failed for user 'sa'.
Source Error:
      An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException: Cannot open database requested in login 'ASPState'. Login
fails.
Login failed for user 'sa'.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnec
tionString options, Boolean& isInTransaction)
   System.Data.SqlClient.SqlConnection.Open()
   System.Web.SessionState.SqlStateConnection..ctor(String
sqlconnectionstring)
[HttpException (0x80004005): Unable to connect to SQL Server session
database.]
   System.Web.SessionState.SqlStateConnection..ctor(String
sqlconnectionstring)
   System.Web.SessionState.SqlStateClientManager.GetConnection(Boolean&
usePooling)
   System.Web.SessionState.SqlStateClientManager.SetAsyncWorker(String id,
SessionStateItem item, Byte[] buf, Int32 length, Boolean inStorage)
System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IState
ClientManager.Set(String id, SessionStateItem item, Boolean inStorage)
   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source,
EventArgs eventArgs)
System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.
Execute()
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)


Relevant Pages

  • new session created when changing pages
    ... I have a set of pages with C# code attached to manage session information. ... They hang their info off of the session string and store it in a MSDE table. ... I have all of this code working well in one app and started another app which ... find that I am get redirected every time I login back to my login because ...
    (microsoft.public.dotnet.framework.aspnet)
  • Session timeout problem...
    ... During the login, in code behind I have dynamically created a public shared ... When the user clicks logout menu option from my app I also have code behind ... session will time out. ... ran some test code in the application start sub in global.ascx to log each ...
    (microsoft.public.dotnet.general)
  • Session object timout
    ... must go through a login page. ... Upon logging in I set some properties in a ... to a session object which I named "CurrentUserInfo". ... Since the app relies on retrieving only information for the company of which ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Running tasks through SSH
    ... > run that task and shut down my SSH session... ... > shut down VNC when I am not checking up on it). ... before running your app, execute screen. ... need to login remotely to resume your screen'd session. ...
    (alt.os.linux.redhat)
  • Re: how do i check if an already opened database has been opened exclusively
    ... > You're only right if the DBC is already opened by you your app in this one ... If the DBC is opened by another session elsewher on the ... > open database my.DBC exclusive ...
    (microsoft.public.fox.helpwanted)