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. Advertising

  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. Advertising

  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. Advertising

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. anand
    Replies:
    4
    Views:
    2,171
    anand
    Jun 17, 2004
  2. Sachin
    Replies:
    2
    Views:
    3,511
    =?Utf-8?B?UyBQ?=
    Mar 5, 2006
  3. Replies:
    2
    Views:
    7,292
    Bruno Alexandre
    Aug 23, 2006
  4. Replies:
    1
    Views:
    343
    Jeff T
    Mar 19, 2007
  5. .Net Sports
    Replies:
    2
    Views:
    409
    .Net Sports
    Jul 28, 2009
Loading...

Share This Page