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,
KevinI 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.
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Kevin" <kevin@.spammers_die.com> wrote in message
news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> 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
Thanks Jerry, that was exactly what I needed.
Kevin
"Jerry Boone" <jerry@.antech.biz.killspam> wrote in message
news:mkmEb.1432$C21.627@.newssvr22.news.prodigy.com ...
> 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.
> --
> Jerry Boone
> Analytical Technologies, Inc.
> http://www.antech.biz
>
> "Kevin" <kevin@.spammers_die.com> wrote in message
> news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> > 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
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment