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.

    "Quentin Huo" <> wrote in message
    news:...
    > 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.
    >
    >
    >
    >
     
    Marina, Sep 1, 2004
    #2
    1. Advertisements

  3. Quentin Huo

    Curt_C [MVP] Guest

    Rows.Count

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Quentin Huo" <> wrote in message
    news:...
    > 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.
    >
    >
    >
    >
     
    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.


    "Marina" <> wrote in message
    news:...
    > Just see how many rows are in your datatable.
    >
    > "Quentin Huo" <> wrote in message
    > news:...
    >> 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
    #4
  5. Quentin Huo

    Marina Guest

    Then you're pretty much stuck with doing a count(*), as far as i know.

    "Quentin Huo" <> wrote in message
    news:...
    > 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.
    >
    >
    > "Marina" <> wrote in message
    > news:...
    > > Just see how many rows are in your datatable.
    > >
    > > "Quentin Huo" <> wrote in message
    > > news:...
    > >> 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.
    > >>
    > >>
    > >>
    > >>

    > >
    > >

    >
    >
     
    Marina, Sep 1, 2004
    #5
  6. 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.

    "Quentin Huo" wrote:

    > 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.
    >
    >
    >
    >
    >
     
    =?Utf-8?B?TWF0dCBIYW1pbHRvbg==?=, Sep 1, 2004
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZGF2aWQ=?=

    How to get the total number of rows in a Dataset?

    =?Utf-8?B?ZGF2aWQ=?=, May 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    18,305
    Yunus Emre ALPĂ–ZEN [MCAD.NET]
    May 3, 2005
  2. Get Total Number Of Pages

    , Dec 9, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    582
    Peter Rilling
    Dec 9, 2005
  3. Mullin
    Replies:
    4
    Views:
    5,641
    Harald
    Jun 12, 2005
  4. Praveen homkar via JavaKB.com

    how to get total number of rows contained in a resultset

    Praveen homkar via JavaKB.com, Aug 5, 2005, in forum: Java
    Replies:
    1
    Views:
    5,573
  5. Replies:
    2
    Views:
    7,566
    Bruno Alexandre
    Aug 23, 2006
  6. Wei  Su
    Replies:
    36
    Views:
    1,296
    Dave Thompson
    Aug 22, 2005
  7. Replies:
    1
    Views:
    446
    Jeff T
    Mar 19, 2007
  8. .Net Sports
    Replies:
    2
    Views:
    505
    .Net Sports
    Jul 28, 2009
Loading...