After retrieving the data from the database, you have to Read
it:
while (myReader.Read())
{
Console.Out.WriteLine(myReader[5].ToString());
}
You can see an example on MSDN.
A couple other notes:
If
myReader[5]
might benull
, then consider usingConvert.ToString(myReader[5])
. That'll return an empty string instead of throwing an exception.If you're using .NET 4.5, there's an alternate syntax you could try:
myReader.GetFieldValue<string>(5)