How to get the row count of a DataReader
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";
}