codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  urgent help with global.asa please  Archive Import (tonya) at 08:41 on Wednesday, May 21, 2003
 

I have set up a global.asa that delivers some info about active users on my site but i have a problem if there are no sessions at all I get an error


ADODB.Recordset error `800a0bcd`

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

//global.asa, line 47


line 47 is
If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast

i need to write a loop or something presumably that says if there are no sessions let me start one or whatever. because with the global.asa file there you cant log into site at all with this error.

heres the code

object runat="Server" scope="Application"
id="rstActiveUsers" progid="ADODB.Recordset">
object>

script language="VBScript" runat="Server">
` The first thing you should notice is the top line.
` It creates an application scoped recordset object
` named rstActiveUsers that I`ll use to store all
` our user information.
`
` Note: I`ve wrapped it for readability

Sub Application_OnStart()
` Selected constants from adovbs.inc
Const adInteger = 3
Const adVarChar = 200
Const adDate = 7

` Here I set up in memory active user recordset
` by adding the fields I want to it and defining
` their data types.
rstActiveUsers.Fields.Append "id", adInteger
rstActiveUsers.Fields.Append "ip", adVarChar, 15
rstActiveUsers.Fields.Append "browser", adVarChar, 255
rstActiveUsers.Fields.Append "started", adDate
rstActiveUsers.Fields.Append "username", adVarChar, 255

` Next I open our recordset so that we can use it.
` That basically gets everything ready for our
` first user.
rstActiveUsers.Open
End Sub

Sub Session_OnStart()
` Set session timeout to 20 minutes
Session.Timeout = 20

` Set a session start time. This is pretty pointless,
` but it does ensure that we start a session and
` assign the user a session id and it can help
` troubleshooting if we ever need it.
Session("Start") = Now()

` Move to the end so records are added in order.
` Again not of any real importance, but it keeps our
` user table nice and orderly.
If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast

` Add a record and insert users data. I`m just
` storing some basic info, but naturally you`re free
` to store whatever you want.
rstActiveUsers.AddNew

rstActiveUsers.Fields("id").Value = _
Session.SessionID

rstActiveUsers.Fields("ip").Value = _
Request.ServerVariables("REMOTE_HOST")

rstActiveUsers.Fields("browser").Value = _
Request.ServerVariables("HTTP_USER_AGENT")

rstActiveUsers.Fields("started").Value = _
Now()


rstActiveUsers.Update

` Now that we`ve got the information, all that`s
` left is to display it. See test_page.asp for a
` demo. It includes the pages show_count.asp and
` show_users.asp which can also be used
` individually if desired.
End Sub

Sub Session_OnEnd()
` Selected constants from adovbs.inc
Const adSearchForward = 1
Const adBookmarkFirst = 1
Const adAffectCurrent = 1

` Find the appropriate record. Using session id is the
` easiest way since I use this as the primary key.
` This line positions us on the appropriate record.
rstActiveUsers.Find "id = " & Session.SessionID, _
0, adSearchForward, adBookmarkFirst

` Now that we`re on the record, delete it.
` I use the EOF to make sure we`ve got one.
If Not rstActiveUsers.EOF Then
rstActiveUsers.Delete adAffectCurrent
End If
End Sub

Sub Application_OnEnd()
` Not like it really matters, but for the sake of
` good coding practice I close the recordset when
` our application is shutting down.
rstActiveUsers.Close
End Sub
script>

  Re: urgent help with global.asa please  Elain at 08:11 on Tuesday, November 09, 2010
 

I suggest that you could search this question on Google, because i always find out the answer from google!
------------------------------------
flash banner|logo maker|flash menu








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: open excel file in html page
•  Re: Connection Problem help needed
•  Re: Open Excel in HTML page
•  Re: losing session between servlets
•  Re: Modifying Excel files
•  Re: insert picture into email
•  Join DZone Q&A webcast with Chris Hostetter
•  delete a lots of records
•  Re: add 6 working days


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010