Ask a Question related to ASP.NET General, Design and Development.
-
Arjen #1
Datareader, there is no data...
Hello,
How can I check the recordcount?
Here is a little bit of my code:
// Load first row into Datareader
dr.Read();
if (dr["Category"].ToString() == "xmlsrc") {
When I do this I get an error because there is no data... it only have to
check this dr["Category"].ToString() == "xmlsrc") if there is data.
How can I do that?
Thanks!
Arjen Guest
-
Datareader, Datagrid and hyperlinks
I am filling a datareader and then assigning the reader to the datagrid as follows: SqlDataReader reader = ADOConnect.populateDatareader();... -
DG-Edit-Loosing data; bound columns - pushbuttons; dataReader
Dear Readers, I am using C# (vb examples will work for me too - i am vb progrmr). I created a dg (datagrid) with bound columns (hesistant to... -
need an example of running conditions against data in a DataReader.
Could someone post an example of conditional evaluation of a data from a database using the dataReader class that builds a new row if a field is not... -
datareader.getstring(0) error
Hi, my code is very simple. dim cm as oledbcommand= new oledbcommand("select * from page " ,cn) cn.open() Dim dr As OleDbDataReader =... -
can't getstring & display datareader
Hi, I want to display a single record datareader and get a value from it. But I can't do both together. After "dim dr as... -
Arjen #2
Re: Datareader, there is no data...
When I search for your best practice with google.com I don't find al lot of
material.
[url]http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=ColumnEnum&lr=[/url]
What namespace do I have to use for ColumnEnum?
Thanks!
"PJ" <pjwalNOSPAM@hotmail.com> schreef in bericht
news:#VjCicnVDHA.2040@TK2MSFTNGP10.phx.gbl...to> the .Read() method returns false if it has reached the end of it's record
> stream so your code should be
>
> if ( dr.Read() )
> {
> //perform actions on row
> }
>
> and...btw, use enums rather than strings to access your columns...it's
> quicker
>
> if ( (string)dr[Convert.ToInt32(ColumnEnum.Category)] == "xmlsrc" )
> //...
>
> "Arjen" <boah123@hotmail.com> wrote in message
> news:bg7ufi$mro$1@news4.tilbu1.nb.home.nl...> > Hello,
> >
> > How can I check the recordcount?
> >
> > Here is a little bit of my code:
> > // Load first row into Datareader
> > dr.Read();
> >
> > if (dr["Category"].ToString() == "xmlsrc") {
> >
> > When I do this I get an error because there is no data... it only have>> > check this dr["Category"].ToString() == "xmlsrc") if there is data.
> > How can I do that?
> >
> > Thanks!
> >
> >
>
Arjen Guest
-
PJ #3
Re: Datareader, there is no data...
ColumnEnum was just an example of an enum you would create to access the
columns in your SqlDataReader
enum ColumnEnum
{
Id, Category, etc
}
this way you are accessing the columns by their int index, rather than their
name, which is obviously faster.
"Arjen" <boah123@hotmail.com> wrote in message
news:bg834s$62h$1@news2.tilbu1.nb.home.nl...of> When I search for your best practice with google.com I don't find al lotrecord> material.
>
> [url]http://www.google.nl/search?hl=nl&ie=UTF-8&oe=UTF-8&q=ColumnEnum&lr=[/url]
>
> What namespace do I have to use for ColumnEnum?
>
> Thanks!
>
>
>
> "PJ" <pjwalNOSPAM@hotmail.com> schreef in bericht
> news:#VjCicnVDHA.2040@TK2MSFTNGP10.phx.gbl...> > the .Read() method returns false if it has reached the end of it's> to> > stream so your code should be
> >
> > if ( dr.Read() )
> > {
> > //perform actions on row
> > }
> >
> > and...btw, use enums rather than strings to access your columns...it's
> > quicker
> >
> > if ( (string)dr[Convert.ToInt32(ColumnEnum.Category)] == "xmlsrc" )
> > //...
> >
> > "Arjen" <boah123@hotmail.com> wrote in message
> > news:bg7ufi$mro$1@news4.tilbu1.nb.home.nl...> > > Hello,
> > >
> > > How can I check the recordcount?
> > >
> > > Here is a little bit of my code:
> > > // Load first row into Datareader
> > > dr.Read();
> > >
> > > if (dr["Category"].ToString() == "xmlsrc") {
> > >
> > > When I do this I get an error because there is no data... it only have>> >> > > check this dr["Category"].ToString() == "xmlsrc") if there is data.
> > > How can I do that?
> > >
> > > Thanks!
> > >
> > >
> >
>
PJ Guest



Reply With Quote

