How to get the total number of queried records?

  • Thread starter Thread starter Quentin Huo
  • Start date Start date
Q

Quentin Huo

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.
 
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.
 
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.
 
Back
Top