SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting SQL Count value into variable

    Hi all,

    I'm trying to implement a pagination feature in my search page and I'm wondering how I can get and use the value that's returned from this SQL statement:

    SELECT COUNT(*) FROM TableName WHERE Assigned = 'name'

    I've run this query in the database query analyzer and it returned 19 however when I attempt the code on my page I get a 500 error.

    Here's the page code:

    Code ASP:
    Set row = conn.Execute("SELECT COUNT(*) FROM TableName WHERE Assigned = 'Name'")

    HTML Code:
    <div id="resultTest"> <%=row%> </div>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code ASP:
    Set row = conn.Execute("SELECT COUNT(*) AS RowCount FROM TableName WHERE Assigned = 'Name'")
    Code HTML:
    <div id="resultTest"> <%=row("RowCount")%> </div>)
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    Code ASP:
    Set row = conn.Execute("SELECT COUNT(*) AS RowCount FROM TableName WHERE Assigned = 'Name'")
    Code HTML:
    <div id="resultTest"> <%=row("RowCount")%> </div>)
    Ah yes!

    I tried doing exactly that except I forgot the quotation marks on "RowCount". Blast... It's always the smallest thing.

    Thanks so much for your help!!


Tags for this Thread

Bookmarks

Posting Permissions

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