By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,808 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

Record Count

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Kulwinder Sayal wrote:
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
Nov 18 '05 #2

P: n/a
Kulwinder Sayal wrote:
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
Nov 18 '05 #3

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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

Nov 18 '05 #4

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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

Nov 18 '05 #5

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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

Nov 18 '05 #6

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
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

Nov 18 '05 #7

P: n/a
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
Nov 18 '05 #8

P: n/a
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
Nov 18 '05 #9

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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,
Kulwinder

Nov 18 '05 #10

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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,
Kulwinder

Nov 18 '05 #11

P: n/a
The following page on the MSDN Library contains an example:

http://msdn.microsoft.com/library/de...datareader.asp

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

"Kulwinder Sayal" <an*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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,
Kulwinder

Nov 18 '05 #12

P: n/a
The following page on the MSDN Library contains an example:

http://msdn.microsoft.com/library/de...datareader.asp

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

"Kulwinder Sayal" <an*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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,
Kulwinder

Nov 18 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.