ADO in global.asa

M

Mac Davis

Is it possible to use ADO in global.asa?
I simply want to creat a log of each visit to the site?

Thanks,

-dmd-
 
R

Ray at

Yes. What do you want to, exactly? You can open an ADO connection, execute
a query, close and destroy your connection in Session_onStart, for example,
if you choose.

Ray at work
 
M

Mac Davis

The follwing is in Session_Onstart
I know the connectionstring is correct because it works on other pages.
I simply want to add a record to do_userlog

---------------------------------------------------------------------
dim TimeSt
dim sq
dim sqlstr

sq = chr (39)
TimeSt = now

session ("connectionstring") = "Provider=SQLOLEDB.1; Data Source=xxxxx;
Initial Catalog=xxxxx; User ID=xxxxx;Password=xxxxx"

set objconn = server.createobject ("ADODB.connection")
set objrec = server.createobject ("ADODB.recordset")

objconn.connectionstring = session ("connectionstring")

sqlstr = "insert into do_userlog (timdate, logid, password, viewed) values
("
'sqlstr = sqlstr & sq & timest & sq & "," & sq & "0101150" & sq & "," & sq &
"004650" & sq & "," & sq & "F" & sq & ")"

sqlstr = "select * from do_events order by postdate desc"

objconn.open
objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly

set objrec = nothing
set objconn = nothing
----------------------------------------------------------------------------
--
The following error is returned
ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

/LM/W3SVC/1002338185/Root/global.asa, line 48

----------------------------------------------------------------------------
---

so, to simplify for troubleshooting I change sqlstr to sqlstr = "select *
from do_events order by postdate desc"

which works fine on other pages, and I receive exactly the same error.



-dmd-
 
B

Bob Barrows

Mac said:
The follwing is in Session_Onstart
I know the connectionstring is correct because it works on other
pages.
I simply want to add a record to do_userlog

---------------------------------------------------------------------
objconn.open
objrec.open sqlstr, objconn, adOpenStatic, adLockReadOnly

The following error is returned
ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

This error means that you do not have the ado constants (adOpenStatic, etc.)
defined on this page. You will either need to define them yourself (you can
look up the Const statements in the adovbs.inc file), or use the method
shown here:
http://www.aspfaq.com/show.asp?id=2112

HTH,
Bob Barrows
 
R

Ray at

Your first step would be to take this out of your onStart and put it in a
normal page so you can debug it. Then, instead of executing your sqlstr
query, response.Write it so you can see it. I think you may find that the
result is:

insert into do_userlog (timdate, logid, password, viewed) values(

You have the rest of your sqlstr commented out (').

Oh, wait, no, you're overwriting your first SQL query.

Also, since you're doing an insert, don't create a recordset. Just insert.

Also, did you define your adOpenStatic and adlockrEadOnly constants?

Also, "password" is a reserved SQL word, so you should bracket it.

Try this in a normal .asp file:

---------------------------------------------------------------------
dim TimeSt
dim sq
dim sqlstr

sq = chr (39)
TimeSt = now

session ("connectionstring") = "Provider=SQLOLEDB.1; Data
Source=xxxxx;Initial Catalog=xxxxx; User ID=xxxxx;Password=xxxxx"
sqlstr = "insert into do_userlog (timdate, logid, [password], viewed) values
("
sqlstr = sqlstr & sq & timest & sq & "," & sq & "0101150" & sq & "," & sq &
"004650" & sq & "," & sq & "F" & sq & ")"

objconn.open session("connectionstring") ''careful
'objconn.execute sqlstr
RESPONSE.WRITE SQLSTR
objconn.close
set objconn = nothing
---------------------------------------------------------------------


Ray at work
 
M

Mac Davis

Thanks Bob,

Added the constants and all is well.

If only the obvious were obvious I obviously wouldn't have to ask so many
questions.

-dmd-
 
M

Mac Davis

Okay, now one more question.
The default page for this site is a frameset page with three .asp pages in
the frame.

What is happening now when someone visits the site is thatI get three logins
entries in the table for the initial visit. Is this because the three asp
pages are in effect accessed simultaneously?

What I want is one entry in the table every time someone hits the site. I
was doing this with a session variable. Seemed like doing it through the
global.asa was cleaner. any thoughts?

Thanks again

-dmd-
 
M

Mac Davis

Thanks,

My problem was that I was referring to the constants in the adovbs.inc file
and the file was not included.
I added the constants to global.asa and it works fine.

-dmd-
 

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

Similar Threads

Global.asa 5
Session.Timeout in global.asa? 1
Global.asa 1
global.asa in subdirectory 4
include file in global.asa 6
Global.asa 0
global.asa 9
Sub Procedure in Global.asa 2

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top