Skip to content

Instantly share code, notes, and snippets.

@timvw
Created January 27, 2013 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timvw/4646799 to your computer and use it in GitHub Desktop.
Save timvw/4646799 to your computer and use it in GitHub Desktop.
public static class SqlCommandExtensions
{
public static void ResultsToConsole(this SqlCommand sqlCommand)
{
using (var sqlDataReader = sqlCommand.ExecuteReader())
{
while (sqlDataReader.Read())
{
Console.WriteLine();
for (var i = 0; i < sqlDataReader.FieldCount; ++i)
{
Console.Write(sqlDataReader.GetName(i));
Console.Write(":");
Console.Write(sqlDataReader.GetValue(i));
Console.Write(", ");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment