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.ExecuteReader().
Something like:
MyDbClass db = new MyDbClass("SELECT * FROM tblUsers");
foreach(MyRecordClass record in db.getRecordSet())
{
Console.WriteLine(MyRecordClass["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