Trouble getting row count from DataReader

K

Kevin

I am using the DataReader to populate an ASP table dynamically. I would
like to set the tables "visible" property based on the the data from my
query. For example, if I have at least one row of data, I will set visible
to true, otherwise, false.

How get I find out if I have at least one row of data? The code below is
from the CodeBehind of my asp form.

*****************************
OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmd = new OracleCommand("select * from customer where name =
'BOB', conn);
try
{
conn.Open();
IDataReader reader = cmd.ExecuteReader();
_grid.DataSource = reader;
_grid.DataBind();
}
finally
{
conn.Dispose();
}
*****************************

Thanks,
Kevin
 
J

Jerry Boone

I think your only option on a DataReader is to use the .Read property. It
returns false if it can't produce a record.

Otherwise, a dataset is necessary to get the actual record count.
 

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
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top