DATAREADER
HOW TO USE DATAREADER IN C#.NET
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Subhendu DePosted Dec 14, 2010, 2:32 AM
using (SqlConnection _connection = new SqlConnection(_connectString))
{
SqlCommand _command = new SqlCommand();
_command.Connection = _connection;
_command.CommandText = "SELECT * FROM RDLCTable";
_command.CommandType = CommandType.Text;
_connection.Open();
IDataReader _reader = _command.ExecuteReader();
while (_reader.Read())
{
Console.WriteLine(_reader["Test"]);
Console.WriteLine(_reader["Param"]);
}
_connection.Close();
}