469,949 Members | 2,180 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,949 developers. It's quick & easy.

ADO in global.asa

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

Thanks,

-dmd-
Jul 19 '05 #1
7 4644
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

"Mac Davis" <ne**@blindsided.org> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
Is it possible to use ADO in global.asa?
I simply want to creat a log of each visit to the site?

Thanks,

-dmd-

Jul 19 '05 #2
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-


"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

"Mac Davis" <ne**@blindsided.org> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
Is it possible to use ADO in global.asa?
I simply want to creat a log of each visit to the site?

Thanks,

-dmd-


Jul 19 '05 #3
Mac Davis wrote:
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
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #4
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




"Mac Davis" <ne**@blindsided.org> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
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-


"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

"Mac Davis" <ne**@blindsided.org> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
Is it possible to use ADO in global.asa?
I simply want to creat a log of each visit to the site?

Thanks,

-dmd-



Jul 19 '05 #5
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-


"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Mac Davis wrote:
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
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #6
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-

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Mac Davis wrote:
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
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #7
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-
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

"Mac Davis" <ne**@blindsided.org> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
Is it possible to use ADO in global.asa?
I simply want to creat a log of each visit to the site?

Thanks,

-dmd-


Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by David Hitillambeau | last post: by
1 post views Thread by Andr? Roberge | last post: by
10 posts views Thread by David P. Donahue | last post: by
22 posts views Thread by fd123456 | last post: by
8 posts views Thread by Rob T | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.