Microsoft Docs

SqlDataReader Class

The SqlDataReader provides a way of reading a forward-only stream of rows from a SQL Server database. It is optimized for performance and uses a minimal amount of memory.

Namespace

System.Data.SqlClient

Assembly

System.Data.dll

Inheritance

Object → DbDataReader → SqlDataReader

Syntax

public sealed class SqlDataReader : DbDataReader, IDataReader, IEnumerable, IDisposable

Remarks

Use the ExecuteReader method of SqlCommand to obtain an instance of SqlDataReader. The reader is forward-only, read-only, and provides methods to retrieve column values by name or ordinal. Remember to call Close (or wrap the reader in a using statement) to free the associated connection.

See Also