Record Count

G

Guest

Hi

In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched

Thanks
Kulwinder
 
A

Ashish Sharma

Kulwinder said:
Hi,

In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched?

Thanks,
Kulwinder

DataSet.Tables(0).Rows.Count
 
Z

zveda

What DB are you using? If SQL Server, are you using stored procedures or
dynamic SQL? Are you using ADO.NET? Help us help you: tell us more about
what you are trying to accomplish.



Kulwinder Sayal said:
Hi,

In ASP it was so simple to get the no. of records using RecordCount. Can
anyone help me how to write the no. of records my sqlquery has searched?
 
K

Kevin Spencer

Actually, ASP has no methods for connecting with a database. You're
referring to ADO (ActiveX Data Objects). There are more than one set of
classes for working with databases in the .Net platform. Most likely, you
are tlaking about either a DataReader, DataSet or a DataTable. A DataReader
is a forward-only, read-only cursor, from which you can not get a count of
records until it is closed. The best way with a DataReader is to count as
you loop through the records. A DataSet is not a container for database
results per se, but a container for DataTables. A DataTable is a complete
RecordSet fetched from a data source. It has a Rows Collection of all the
rows of data in the Result Set. You can get a count by checking the Count
property of the Rows Collection. Example:

int intCt = MyDataTable.Rows.Count;

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kulwinder Sayal said:
Hi,

In ASP it was so simple to get the no. of records using RecordCount. Can
anyone help me how to write the no. of records my sqlquery has searched?
 
G

Guest

Hi

I'm using SQL Server and Data Reader to get the record. IF I can't do the record count while i'm using data reader, how can i count the no. of search results??

Please help... Give me a nice example

TIA
Kulwinde
 
K

Kevin Spencer

You might want to re-read my message. I told you how to do it in the
message:

" The best way with a DataReader is to count as you loop through the
records. "

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kulwinder Sayal said:
Hi,

I'm using SQL Server and Data Reader to get the record. IF I can't do the
record count while i'm using data reader, how can i count the no. of search
results???
 
Joined
Mar 18, 2009
Messages
5
Reaction score
0
I may have misunderstood what you're trying to do but couldn't you simply get a record count from the SQL SelectCommand in your data source - SELECT COUNT(*) AS RecordCount. You could then bind this to a control using <%#Eval("RecordCount")%> in the template.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top