Re: Database interactions don't fire from Application_Start in Global.asax?
- From: "Juan T. Llibre" <nomailreplies@xxxxxxxxxxx>
- Date: Fri, 16 Jun 2006 09:33:50 -0400
Please review this article which details the Application lifecycle :
http://msdn2.microsoft.com/en-us/library/ms178473.aspx
Application_Start fires *once* in the application's life.
You cannot use it to capture data about individual users.
Try putting your code in the Session_Start event handler in global.asax.
btw, you'll need to modify your code so that
1. it actually inserts the session id into your database
2. It doesn't use MsgBox ( Msgbox runs client-side, not server-side )
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Christian Blackburn" <christian.Blackburn@xxxxxxxxx> wrote in message
news:1150442804.646872.26720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Gang,
Let me start by saying I'm using Visual Web Developer 2005 and ASP.net
2.0. Is there something I have to do to get my Global.asax fire when
my application loads. If I set a breakpoint nothing happens also I can
tell that it's not updating my database. I'm storing the users's
session ID in the database to prevent multiple logins. However, when
their session expires it's not clearning their record. Are there
prohibitive constraints on the functionality accessible from
Global.asax?
Thanks a bundle,
Christian Blackburn
-------------------------------------------------------------------------------------------------------------------------------------
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
'Creates the database's Connection object
Dim oConn As New System.Data.Odbc.OdbcConnection("DSN=" &
strDSN)
'Creates a Command object
Dim oCommand As New System.Data.Odbc.OdbcCommand
'Opens the connection
oConn.Open()
'Specifies the command to execute,
'we're clearing all the recorded session IDs
oCommand.CommandText = "UPDATE users " & vbCrLf & _
"SET session_id = '';"
MsgBox(oCommand.CommandText)
'Tells the command object to use the connection above
oCommand.Connection = oConn
'Executes the command
oCommand.ExecuteNonQuery()
'Closes the database connection
oConn.Close()
End Sub
-------------------------------------------------------------------------------------------------------------------------------------
.
- Follow-Ups:
- References:
- Database interactions don't fire from Application_Start in Global.asax?
- From: Christian Blackburn
- Database interactions don't fire from Application_Start in Global.asax?
- Prev by Date: Re: How can I prevent Sessions from ending just because the browser window is closed
- Next by Date: Foreign Languages?
- Previous by thread: Re: Database interactions don't fire from Application_Start in Global.asax?
- Next by thread: Re: Database interactions don't fire from Application_Start in Global.asax?
- Index(es):
Relevant Pages
|