Print Recordset Details from IDataReader

Occasionally when working with recordsets returned by a stored procedure in an IDataReader, it can be helpful to print information about the columns returned. I like to do this when making a DTO class that mirrors a recordset to ensure that my class’s properties are typed consistently with the recordset. Printing the column details can be accomplished easily with the following code:

IDataReader reader = GetDataReader();
for (int i = 0; i < reader.FieldCount; i++)
    Console.WriteLine("Name:{0}, Type:{1}",

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s