How to get the total number of queried records?

Discussion in 'ASP .Net' started by Quentin Huo, Sep 1, 2004.

  1. Quentin Huo

    Quentin Huo Guest

    Hi:

    I want to retrieve a set of records from the query like:

    "SELECT * FROM tVisitors WHERE vTime>'1/1/2004'"

    And then I will put a part of records into a DataSet by:

    DataSet ds = new DataSet();

    myAdapter.Fill( ds , startrecordnumber , pagesize , "tVisitors");



    But I still need the total number to do something else, I don't think it's a
    good idea to query again like:

    Select Count(*) from tVisitor where vTime>'1/1/2004'

    But any better idea?



    Thanks



    Q.
     
    Quentin Huo, Sep 1, 2004
    #1
    1. Advertisements

  2. Quentin Huo

    Marina Guest

    Just see how many rows are in your datatable.
     
    Marina, Sep 1, 2004
    #2
    1. Advertisements

  3. Quentin Huo

    Curt_C [MVP] Guest

    Rows.Count
     
    Curt_C [MVP], Sep 1, 2004
    #3
  4. Quentin Huo

    Quentin Huo Guest

    Hi, thanks

    using row.count doesn't work!

    if there may be100 records retrieved from the sql script, but there are 20
    records, for example only the records from 10th to 29th are Filled into the
    table of the DataSet by

    myAdapter.Fill( ds , 10, 20, "tVisitors");

    so rows.count will only return 20, but not 100.

    Q.
     
    Quentin Huo, Sep 1, 2004
    #4
  5. Quentin Huo

    Marina Guest

    Then you're pretty much stuck with doing a count(*), as far as i know.
     
    Marina, Sep 1, 2004
    #5
  6. Quentin Huo

    Guest Guest

    I would populate the entire dataset, then use the default veiw to filter
    rows. Then you can use rows.count and get the best of both worlds.
     
    Guest, Sep 1, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.