When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Saturday, July 17, 1999

Using Custom Recordsets, Part 2

By Ryan S.


  • Read Using Custom Recordsets, Part 1
  • In Part 1 we looked at how to create our very own custom recordset. In this part, we are going to look at how we can use this custom recordset in our ASP application!

    - continued -

    Let's say that you want to determine the current user's IP. Well, this ain't too hard:

    'Lock the Application scope
    Application.Lock

    'Get the row based on the Session("ID") for this user
    CustomRS.Find("ID = '" & Session("ID") & "'")

    Response.Write "Your IP is " & CustomRS("IP")

    'Unlock the Application Scope
    Application.UnLock

    Now, what if you want to know the total number of visitors on your website right now? That's easy too!

    'Lock the Application scope
    Application.Lock

    Response.Write "There are " & CustomRS.RecordCount & " visitors on-line right now!"
    'Unlock the Application Scope
    Application.UnLock

    (Note: if all you want to do is see the number of simultaneous visitors on your site, there is a less memory-intensive way to do this. See Joao's aritlce How Many People Are on your Site Right Now?)

    Now, here's the neatest part. You can see a listing of all the folks who are on your site in real time! Just iterate through the recordset:

    'Lock the Application scope...
    Application.Lock
    
    'Move to the first record in our custom recordset
    CustomRS.MoveFirst
    
    'Loop through the recordset...
    Do While Not CustomRS.EOF
    	Response.Write "User: " & CustomRS("ID") & "<BR>"
    	Response.Write "IP: " & CustomRS("IP") & "<BR>"
    	Response.Write "Came on-line at: " & CustomRS("LogOn")
    	Response.Write "<P><HR><P>"
    	
    	CustomRS.MoveNext
    Loop
    
    'Unlock the application...
    Application.UnLock
    

    It's that easy. Pretty freakin' cool, in my opinion.

    Mad props to Professional ADO RDS Programming with ASP, who introduced me to custom recordsets. Mad props to Scott for giving it to me ;-)

    Anyway, hope you had fun with the scriptlet, and as always, God bless from Ryan S

  • Read Using Custom Recordsets, Part 1

  • Attachments:

  • Global.asa for this article


    This article was written by Ryan S. Ryan has been a computer programmer in the loosest sense since the age of 8. He has been working with ASP since the age of 13, when it first came out (that he knows of), and is somewhat advanced at it.


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article