Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the row count of a DataReader

bishopkc99Sep 19 2003 — edited Aug 27 2004
Using Oracle Data Provider for .NET 9.2.0.4.0 Beta

I am building an ASP.NET page that does a select against an Oracle DB. The data is then displayed into a data grid.

1. OracleDataReader reader = cmd.ExecuteReader();
2. dgResults.DataSource = reader;
3. dgResults.DataBind();

After I execute line 1 I want to find out if the reader has any rows in it. How is this done???

I have tried the solution below, which does work when there is no data but when I do have data, the data does not appear in my data grid. It seems like my reader has lost the data. Any help would be greatly appreciated!!!

OracleDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
dgResults.DataSource = reader;
dgResults.DataBind();
}
else
{
txtProblems.Value = "No Data";
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2004
Added on Sep 19 2003
5 comments
14,187 views