Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

How to Read data with SqlDataReader Object in ADO.Net?
SqlDataReader rdr = cmd.ExecuteReader();
The typical method of reading from the data stream returned by the SqlDataReader is to iterate through each row with a while loop.
while (rdr.Read())
{
string conta = (string)rdr["ContactName"];
string comp = (string)rdr["CompanyName"];
string cty    = (string)rdr["City"];
Console.Write("{0,-25}", conta);
Console.Write("{0,-20}", cty);
Console.Write("{0,-25}", comp);
Console.WriteLine();
}