Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
global.asa file help.
Old 06-10-2006, 06:13 AM global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Hello, I am creating a Who Is Logged In page which wont seem to work. I have fixed a few errors, but cant get past this one.

Sorry about the code below, but better that I show the lot rather than mess around. So far I have the following.

admin.asp
<!-- #include file="show_count.asp" -->
<!-- #include file="show_users.asp" -->

show_count.asp
<%= rsActiveUsers.RecordCount %>


show_users.asp
<%
If rsActiveUsers.RecordCount > 0 Then
rsActiveUsers.MoveFirst
Response.Write "<table border=""1"">" & vbCrLf
Response.Write " <thead>" & vbCrLf
Response.Write " <th>Session Id</td>" & vbCrLf
Response.Write " <th>IP Address</th>" & vbCrLf
Response.Write " <th>User Agent</th>" & vbCrLf
Response.Write " <th>Session Start Time</th>" & vbCrLf
Response.Write " </thead>" & vbCrLf
Do While Not rsActiveUsers.EOF
Response.Write " <tr>" & vbCrLf
Response.Write " <td>" & rsActiveUsers.Fields("id").Value & "</td>" & vbCrLf
Response.Write " <td>" & rsActiveUsers.Fields("ip").Value & "</td>" & vbCrLf
Response.Write " <td>" & rsActiveUsers.Fields("browser").Value & "</td>" & vbCrLf
Response.Write " <td>" & rsActiveUsers.Fields("started").Value & "</td>" & vbCrLf
Response.Write " </tr>" & vbCrLf
rsActiveUsers.MoveNext
Loop
Response.Write "</table>" & vbCrLf
End If
%>



When I load the admin.asp page I get the following...
-1 Active Users
Users


It dosent seem to work.

Any suggestions?

Last edited by malhyp; 06-10-2006 at 09:39 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-10-2006, 07:42 AM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Mally

Last edited by malhyp; 06-10-2006 at 09:39 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-10-2006, 08:49 AM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Ooops, I left this out...

global.asa

<object runat="Server" scope="Application"
id="rsActiveUsers" progid="ADODB.Recordset">
</object>
<script language="VBScript" runat="Server">
Sub Application_OnStart()
Const adInteger = 3
Const adVarChar = 200
Const adDate = 7

rsActiveUsers.Fields.Append "id", adInteger
rsActiveUsers.Fields.Append "ip", adVarChar, 15
rsActiveUsers.Fields.Append "browser", adVarChar, 255
rsActiveUsers.Fields.Append "started", adDate
rsActiveUsers.Open
End Sub
Sub Session_OnStart()
Session.Timeout = 20
Session("Start") = Now()

If Not rsActiveUsers.EOF Then rsActiveUsers.MoveLast
rsActiveUsers.AddNew

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

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

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

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

rsActiveUsers.Update

End Sub
Sub Session_OnEnd()
Const adSearchForward = 1
Const adBookmarkFirst = 1
Const adAffectCurrent = 1
rsActiveUsers.Find "id = " & Session.SessionID, _
0, adSearchForward, adBookmarkFirst

If Not rsActiveUsers.EOF Then
rsActiveUsers.Delete adAffectCurrent
End If
End Sub
Sub Application_OnEnd()
rsActiveUsers.Close
End Sub
</script>
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-10-2006, 05:20 PM Re: global.asa file help.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you need to use a clientside cursor to return the correct value for objRS.recordcount

add rsActiveUsers.CursorLocation = 3 (or adUseClient if you have the adovbs.inc file) before you open the Recordset
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-10-2006, 08:55 PM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
I do have a copy of the <!-- #include file="adovbs.inc" --> file. The latest one I can find is 1999. Am I including this in the global.asa? At the very top?

Mally.
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-10-2006, 09:31 PM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Is say that my last quote is incorrect. I have included it at the top of my admin.asp page.

It still hasent worked, so I think that there must be something that I havent set up but I dont know what it is...

Mally
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-10-2006, 09:38 PM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Not sure if it helps at all, but I still the <%=Application("CurrentNumberOfUsers")%> in the admin.asp page which now seems to be working again.

This file was from an older version of the global.asa which I have since deleted. But its now working, even though there is no referance in the new version of global.asa of CurrentNumberOfUsers...

The reason for getting rid of the old one is because it only told how many users were online.

The new bersion will do this and also tell who they are.

I have included an old copy of the global.asa file which is not installed.

Code:
<script language="vbscript" runat="server">
Sub Session_OnStart
Session("StartTime") = Now()
Application.Lock
Application("TotalNumberOfUsers") = _
Application("TotalNumberOfUsers") + 1
Application("CurrentNumberOfUsers") = _
Application("CurrentNumberOfUsers") + 1
Application.Unlock
End Sub
Sub Session_OnEnd
Application.Lock
Application("CurrentNumberOfUsers") = _
Application("CurrentNumberOfUsers") - 1
Application.Unlock
End Sub
Sub Application_OnStart
Application("EMailAddress") = "ii15@hotmail.com"
Application("TotalNumberOfUsers")=0
Application("CurrentNumberOfUsers")=0
End Sub
Sub Application_OnEnd
End Sub
</script>

malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-11-2006, 04:54 AM Re: global.asa file help.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok not quite sure what an old version, which you are not using is supposed to tell me, but heyho.

the adovbs includes needs to be included in every page where you use the constants. If you use the numeric values instead you don't need it at all.

Have you restarted the server since changing the global.asa? It can be cached by the server and will run from the memory version sometimes.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-11-2006, 05:28 AM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Chris, what did you mean by this???
Quote:
Originally Posted by chrishirst
If you use the numeric values instead you don't need it at all.
I have treid re starting it a few times.

Thanks
Mally
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-11-2006, 05:43 AM Re: global.asa file help.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the constant names are there to put a "friendly face" on values and make code more readable. (as with all constants).

objRS.Open strSQL , objConn, adOpenStatic, adLockReadOnly, adCmdText

is simpler to read than

objRS.Open strSQL , objConn, 3, 1, &H0001

but both mean exactly the same thing
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-11-2006, 05:55 AM Re: global.asa file help.
Skilled Talker

Posts: 79
Trades: 0
Hm, Ok.

Thank you.
malhyp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to global.asa file help.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55158 seconds with 12 queries