Hi everyone,
is there a way to access every record from a SqlDataReader via
"foreach" ?
I want to write a class which (besides doing some other stuff)
retrieves a recordset using SqlCommand.Exec uteReader().
Something like:
MyDbClass db = new MyDbClass("SELE CT * FROM tblUsers");
foreach(MyRecor dClass record in db.getRecordSet ())
{
Console.WriteLi ne(MyRecordClas s["UserId"]);
}
I know this has something to do with GetEnumerator (which SqlDataReader
implements) but I don't know how to start or if it's possible at all.
I hope someone can help me out.
Thanks in advance,
Kevin
is there a way to access every record from a SqlDataReader via
"foreach" ?
I want to write a class which (besides doing some other stuff)
retrieves a recordset using SqlCommand.Exec uteReader().
Something like:
MyDbClass db = new MyDbClass("SELE CT * FROM tblUsers");
foreach(MyRecor dClass record in db.getRecordSet ())
{
Console.WriteLi ne(MyRecordClas s["UserId"]);
}
I know this has something to do with GetEnumerator (which SqlDataReader
implements) but I don't know how to start or if it's possible at all.
I hope someone can help me out.
Thanks in advance,
Kevin
Comment