Results 1 to 4 of 4

Thread: Getting count in ASP

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Location
    tampa, fl
    Posts
    4
    can somebody tell me what is wrong with this code.. i am trying to get the count..

    Dim rsMessages2
    Set rsMessages2 = DB.Execute ("SELECT count(*) FROM Messages WHERE ForumID = " & ForumID)

    Response.Write rsMessages2

    the error is on the "Response.Write rsMessages2"

    thanks
    ren

  2. #2
    New Member
    Join Date
    Apr 2001
    Location
    Sweden
    Posts
    4
    Try this:

    <%

    Dim rstCount
    Set rstCount = cnnDb.Execute("SELECT COUNT(*) FROM Messages WHERE ForumId=" & lngForumId & ";")

    Response.Write rstCount(0)

    %>

    .. should work.

  3. #3
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277
    Or you could change this:

    Response.Write rsMessages2

    to say this:

    Response.Write rsMessages2 & "_<BR>"

    That might help, .....
    ~Peter


  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    See if this will work as well. Your problem is that you are trying to write the Recordset Object, not a string.

    Code:
    Dim rsMessages2 
    Set rsMessages2 = DB.Execute ("SELECT count(*) AS MyCount FROM Messages WHERE ForumID = " & ForumID) 
    
    Response.Write rsMessages2.Fields("MyCount")
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width