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" <bo*****@hotmail.com> wrote in message
news:bg**********@news2.tilbu1.nb.home.nl...
When I search for your best practice with google.com I don't find al lot
of material.
http://www.google.nl/search?hl=nl&ie...ColumnEnum&lr=
What namespace do I have to use for ColumnEnum?
Thanks!
"PJ" <pj*********@hotmail.com> schreef in bericht
news:#V**************@TK2MSFTNGP10.phx.gbl... 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" <bo*****@hotmail.com> wrote in message
news:bg**********@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
to check this dr["Category"].ToString() == "xmlsrc") if there is data.
How can I do that?
Thanks!