What is the significance of the SqlDataReader?
The SqlDataReader is used to retrieve data from the database in a forward-only and
read-only manner. It is more efficient than a DataSet when you need to retrieve a large
amount of data quickly and do not need to modify the data. It requires an open connection to
the database and reads data sequentially, one row at a time.
Example:
SqlCommand command = new SqlCommand("SELECT CustomerName FROM
Customers", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
Console.WriteLine(reader["CustomerName"]);
reader.Close();