Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OleDbDataReader-Count Property

Status
Not open for further replies.

TekMem

Programmer
Jul 23, 2004
98
CA
I am using OleDbDataReader to access the data and I have following codes to count number of records.

Opendb()
Do While (myReader.Read())
Counter += 1
Loop
closedb()
These steps slows down the process.
I have to use this count somewhere else with opendb function. Is there a count property or some other suggestion? so that I can count number of records or rows.

Thanks in advance.
 
Use Command.ExecuteScalar to run a SELECT COUNT(*) query rather than looping through a data reader.
 
In the above codes While myreader counts the counter is shown in a label in the form...but some how the counter is shown only when the process is finished.
Need a clue?
Thanks.
 
not that I would recommend this but add an application.doevents in the loop or me.refresh.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
You can also you the count member of the CurrencyManager. Don't know if it would be any faster than an SQL Count(*) query or not. Also with the CurrencyManager, you can obtain the current record's position, etc.
 
PRPhx, I don't think you can use CurrencyManager - a DataReader is read-only, forward-only and doesn't implement any of the interfaces required by the CurrencyManager (Ilist, IListSource and IBindingList).

CurrencyManager is usually used with DataSet, DataTable or DataView.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top