Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Session_OnStart to update a table

Status
Not open for further replies.

moltar

Programmer
Mar 8, 2002
26
US
When I try to update a "visits" field in a "users" table, by using global.asa's Session_OnStart, I get the following error:

ADODB.Recordset error '800a0bb9'

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

//global.asa, line 28


I am fairly certain that this Query statement is correct with how the db "users" table is designed. Here is my code:

Sub Session_OnStart
userID = Request.Cookies("userID")
if userID<>&quot;&quot; then
Set rsOldVisits = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
Query = &quot;SELECT visits FROM users WHERE userID=&quot; & userID
rsOldVisits.Open CStr(Query), conn
if not rsOldVisits.EOF then
old_visits = rsOldVisits(&quot;visits&quot;)
else
old_visits = 0
end if
new_visits = old_visits + 1

Set rsNewVisit = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
Query = &quot;UPDATE users SET visits='&quot; & new_visits & &quot;' WHERE userID='&quot; & userID & &quot;'&quot;
rsNewVisit.Open CStr(Query), conn
end if
End Sub


What am I doing wrong? Thanks!!
 
Hi ...
you have to open your recordset by and oppened connection.
in the line :
rsOldVisits.Open CStr(Query), conn
you have a connection named &quot;conn&quot; where you have not opend it.
so you get this error.
first open you connection.
----
TNX.
E.T.
 
thanks... I added the connection string to the OnStart subroutine, and it worked like a charm. Very cool!

so, is it generally ok to use a db connection in OnStart, as long as it is closed at the end of the Sub?
 
Hi ...
as you had done it and you got no error, so there is no problem.
----
TNX.
E.T.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top