473,372 Members | 1,040 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 4790
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
1
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
7
by: Lyn | last post by:
Hi and Season's Greetings to all. I have a question regarding the use of a qualifier word "Global". I cannot find any reference to this in Access help, nor in books or on the Internet. "Global"...
10
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.