DATAREADER
HOW TO USE DATAREADER IN C#.NET
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 13, 2010, 9:32 PM EST
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();
}