Count Rcords

  • Thread starter Thread starter Anuradha
  • Start date Start date
By reading the records and count them. As a datareader is specialized
for reading a result from start to end, there is no way of getting the
number of records in the result without reading them.

If you only want to know the number of records, you should use a count()
expression in the SQL query instead. That way you only get the
information you need in the result instead of a lot of data that you
don't use.
 
In addition to Göran's post, you can use the ExecuteScalar method of the
DataCommand to retrieve the count.
 
What i mean is I need to check the table and if records found I need to
update another table. I will give a example



Select * from bktrn where EPF='" & text.text & "'



If recodes found then

xxxxxxxxx

end if



how can I do this


Thx
Anuradha
 
As I said, use a count() expression in the query:

Select count(*) from bktrn where EPF='" & text.text & "'

The query will return a single record with a single field, that contains
the number of records that matched the condition.
 
Back
Top