+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 34

Thread: Counting records?

  1. #11
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    J, i think it should be? :

    Code:
    SELECT Count(*) AS MyCount FROM performances WHERE (((performances.Status)=""Available""))"
    
    ???

  2. #12
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Also, since you're using the ADO recordset, you can simply do this:
    Code:
    Dim ticketCount
    ticketCount = availabilityRS.RecordCount
    
    See here: ADO RecordCount Property
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #13
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    The reason I removed the asterisk is for performance reasons. See this Google search for more information: SELECT COUNT performance
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  4. #14
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    Try using the column name in the COUNT function instead:
    Code:
    SELECT Count(performances.performanceid) as MyCount,performances.performanceid,
           shows.showname,
           performances.status
    FROM   shows
           INNER JOIN performances
             ON shows.showid = performances.showid
    WHERE  (((performances.status) = "Available"));
    GROUP BY performances.performanceid, shows.showname, performances.status
    
    That still doesn't count properly.. What i just posted counts correctly in Access and when i implement that in my asp page and then dubug:

    response.write (availabilityRS("MyCount"))

    it shows "1" which is wrong!

  5. #15
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    Also, since you're using the ADO recordset, you can simply do this:
    Code:
    Dim ticketCount
    ticketCount = availabilityRS.RecordCount
    
    See here: ADO RecordCount Property
    I have had a bit of a go with what you posted. Unfortunatly the recordset count displays a "-1" value. Im lost now.. If anyone else knows of a solution, i would appreciate

    edit: think i found the solution.. im gonna try it now

    http://www.slxdeveloper.com/page.asp...e&articleid=33

  6. #16
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by Centurion View Post
    I have had a bit of a go with what you posted. Unfortunatly the recordset count displays a "-1" value. Im lost now.. If anyone else knows of a solution, i would appreciate

    edit: think i found the solution.. im gonna try it now

    How To Retrieve a Record Count From an ADO Recordset by Ryan Farley
    Having looked at the link.. I am having problems getting the page to work..
    my code:

    Code:
    <%
    Option Explicit
    
    <!--#include virtual="adovbs.inc"-->
    
    DIM availabilitySQL, availabilityConn, availabilityRS, adUseClient
    
    set availabilityConn=Server.CreateObject("ADODB.Connection")
    availabilityConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
    availabilityConn.open server.mappath("../db/database.mdb")
    
    'query to check all the shows that are available
    availabilitySQL = "SELECT * FROM shows"
    
    Set availabilityRS = Server.CreateObject("ADODB.Recordset")
    availabilityRS.Open availabilitySQL, availabilityConn
    
    
    With availabilityRS
    	.CursorLocation = adUseClient
    	.Open availabilitySQL, Application.availabilityConn
    
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    Set availabilityRS = Nothing   
    %>
    
    Getting this error:

    ADODB.Recordset error '800a0e79'

    Operation is not allowed when the object is open.

    /groupV2.asp, line 17

  7. #17
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    You are opening it twice:
    Code:
    <%
    Option Explicit
    
    <!--#include virtual="adovbs.inc"-->
    
    DIM availabilitySQL, availabilityConn, availabilityRS, adUseClient
    
    set availabilityConn=Server.CreateObject("ADODB.Connection")
    availabilityConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
    availabilityConn.open server.mappath("../db/database.mdb")
    
    'query to check all the shows that are available
    availabilitySQL = "SELECT * FROM shows"
    
    Set availabilityRS = Server.CreateObject("ADODB.Recordset")
    availabilityRS.Open availabilitySQL, availabilityConn
    
    
    With availabilityRS
    	.CursorLocation = adUseClient
    	.Open availabilitySQL, Application.availabilityConn
    
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    Set availabilityRS = Nothing   
    %>
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  8. #18
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    You are opening it twice:
    Code:
    <%
    Option Explicit
    
    <!--#include virtual="adovbs.inc"-->
    
    DIM availabilitySQL, availabilityConn, availabilityRS, adUseClient
    
    set availabilityConn=Server.CreateObject("ADODB.Connection")
    availabilityConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
    availabilityConn.open server.mappath("../db/database.mdb")
    
    'query to check all the shows that are available
    availabilitySQL = "SELECT * FROM shows"
    
    Set availabilityRS = Server.CreateObject("ADODB.Recordset")
    availabilityRS.Open availabilitySQL, availabilityConn
    
    
    With availabilityRS
    	.CursorLocation = adUseClient
    	.Open availabilitySQL, Application.availabilityConn
    
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    Set availabilityRS = Nothing   
    %>
    
    Nope.. stil doesnt want to run...

    ADODB.Recordset error '800a0e79'

    Operation is not allowed when the object is open.


    The object is supposed to be open thou!???

  9. #19
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Yes, it has to be open, but you are opening it twice. Change this:
    Code:
    With availabilityRS
    	.CursorLocation = adUseClient
    	.Open availabilitySQL, Application.availabilityConn
    
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    
    To this:
    Code:
    With availabilityRS
    	.CursorLocation = adUseClient
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    
    If still errors after that, post the code you have and highlight the line the error is occurring on.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  10. #20
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by jmurrayhead View Post
    Yes, it has to be open, but you are opening it twice. Change this:
    Code:
    With availabilityRS
    	.CursorLocation = adUseClient
    	.Open availabilitySQL, Application.availabilityConn
    
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    
    To this:
    Code:
    With availabilityRS
    	.CursorLocation = adUseClient
    	MsgBox .RecordCount & " records"
    
    	.Close
    End With
    
    If still errors after that, post the code you have and highlight the line the error is occurring on.
    Sorry J, no luck for me.. here is my code:

    Code:
    <%Option Explicit
    
    <!--#include virtual="adovbs.inc"-->
    
    DIM availabilitySQL, availabilityConn, availabilityRS, adUseClient
    
    set availabilityConn=Server.CreateObject("ADODB.Connection")
    availabilityConn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0"
    availabilityConn.open server.mappath("../db/database.mdb")
    
    'query to check all the shows that are available
    availabilitySQL = "SELECT performances.performanceID, shows.showName, performances.status FROM shows INNER JOIN performances ON shows.showID = performances.showID WHERE  (((performances.status) = ""Available"")) GROUP BY performances.performanceID, shows.showName, performances.status"
    
    Set availabilityRS = Server.CreateObject("ADODB.Recordset")
    availabilityRS.Open availabilitySQL, availabilityConn
    
    
    With availabilityRS
    	.CursorLocation = adUseClient
    	MsgBox .RecordCount & " records"
    	.Close
    End With
    Set availabilityRS = Nothing   
    
    %>
    

+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Similar Threads

  1. Counting a field of two columns if the values don't match in SSRS
    By kristilee in forum SQL Server Reporting Services Help
    Replies: 5
    Last Post: September 4th, 2009, 12:21 PM
  2. Adding records
    By todd2006 in forum .NET Development
    Replies: 2
    Last Post: July 21st, 2009, 11:21 PM
  3. Looping Through Records
    By BLaaaaaaaaaarche in forum ASP Development
    Replies: 3
    Last Post: July 15th, 2009, 09:42 PM
  4. Sub/Child Records
    By Flam in forum SQL Development
    Replies: 8
    Last Post: June 16th, 2009, 02:19 PM
  5. comparing records
    By javier_83 in forum Microsoft Access
    Replies: 10
    Last Post: August 7th, 2008, 02:04 PM

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

SEO by vBSEO