SqlDataReader
noun
say it: “ESS-kyoo-EL DAY-tuh REE-der” /ˌɛs kjuː ˈɛl ˈdeɪtə ˈriːdər/
The ADO.NET class that reads a query's rows one at a time, from first to last.
What is SqlDataReader in C#?
SqlDataReader — The ADO.NET object that reads a query's rows one at a time, forward only. Each call to Read() moves to the next row and returns false when there are no more.
using SqlCommand command = new("SELECT CompanyName FROM Shippers", connection);
using SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
In a sentence
- “The SqlDataReader gave me one shipper per call to Read().”
Level: Journeyman · More C# terms at this level
Updated