Slow MDB acess in global.asa

P

Paul Close

Hi Everyone,

The following code runs in less than one second when used in an ASP page but
when used in Session_onStart() in global.asa, the first page in a new
session is delayed by more than thirty seconds. The code seems to work - its
just slooow. Why is this so and how do I fix it?

Dim cnComDoc
Set cnComDoc = Server.CreateObject("ADODB.Connection")
cnComDoc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\comdoc.mdb;Persist Security Info=False"
cnComDoc.execute "Insert into SessionInfo
(SessionID,BeginDateTime,IPAddress) values ('" & Session.SessionID & "','" &
FormatDateTime(now(), vbGeneralDate) & "','" &
Request.ServerVariables("REMOTE_ADDR") & "')",,adCmdText +
adExecuteNoRecords
Set cnComDoc = Nothing
 
P

Phillip Windell

You fix it by not doing it in the Global.asa file. You're supposed to
do it in the ASP file that needs it (use an Include file).


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
P

Phillip Windell

Sorry, I should have added more. Yes the Global.asa would seem to be
the logical place to do this, but from what I've seen it doesn't
always work that well. I assume you are wanting to track a user to see
how long they were there or estimate when they left the site.
If you're wanting to store the Session ID, then you'd want to make
sure that the Session ID doesn't already exist before adding the
record so it doesn't add a duplicate record each time they move to
another page. You probably would want some kind of timestamp that is
updated with each page they go to and then if the timestamp becomes
older than the site's Session Timeout then either delete the record or
do some other action based on that.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
A

Arnold Shore

Good advice, I guess; I've been fighting that symptom. But where does it
say that "You're supposed to do it in the ASP file that needs it"

AS

Phillip Windell said:
You fix it by not doing it in the Global.asa file. You're supposed to
do it in the ASP file that needs it (use an Include file).


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com

Paul Close said:
Hi Everyone,

The following code runs in less than one second when used in an ASP page but
when used in Session_onStart() in global.asa, the first page in a new
session is delayed by more than thirty seconds. The code seems to work - its
just slooow. Why is this so and how do I fix it?

Dim cnComDoc
Set cnComDoc = Server.CreateObject("ADODB.Connection")
cnComDoc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\comdoc.mdb;Persist Security Info=False"
cnComDoc.execute "Insert into SessionInfo
(SessionID,BeginDateTime,IPAddress) values ('" & Session.SessionID & "','" &
FormatDateTime(now(), vbGeneralDate) & "','" &
Request.ServerVariables("REMOTE_ADDR") & "')",,adCmdText +
adExecuteNoRecords
Set cnComDoc = Nothing
 
P

Phillip Windell

Arnold Shore said:
Good advice, I guess; I've been fighting that symptom. But where does it
say that "You're supposed to do it in the ASP file that needs it"

It's the "proverbial it", kinda like the "proverbial they".

It is just the normal principle of only creating what you need when
you need it, then use it, then close or eliminate it as soon as your
finished, rather than do it in the global.asa where it continues to
exist throught the life of the Application.

Plus using it in Include files means if a page doesn't require any
database activity, then the particular Include file isn't used,
therefore no resources are used for a database connection that you
don't need. In other words,...treat each page as its own individual
stand-alone program except for specific situations that require
otherwise. That is the concept that HTTP is built on anyway.

--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top