Core objects and the connected model — ADO.NET
Lesson 1 of 9 in the free ADO.NET — Connected & Disconnected Data Access course on DevLadder. Object Role SqlConnection Connection to the DB (pooled) SqlCommand SQL statement or stored procedure SqlParameter Typed parameter value — prevents SQL injection SqlDataReader Fast, forward-only, read-only stream of rows SqlDataAdapter Bridge between DB and DataSet DataSet / DataTable In-memory relational…
ADO.NET is Microsoft's core data access library for the .NET framework, comprising System.Data and provider packages. Its primary objects include Connection, Command, Parameter, DataReader, DataAdapter, DataSet, DataTable, and Transaction.
Connected architecture maintains an open connection while reading data through a DataReader, which is fast and memory-efficient but limited in flexibility. Disconnected architecture involves filling a DataSet or DataTable with data, allowing for navigation, editing, and later updates to the database using Update(). Modern applications generally prefer the connected model, often utilizing Dapper or Entity Framework (EF) for efficiency.
The difference between ExecuteReader, ExecuteScalar, and ExecuteNonQuery lies in their return values. ExecuteReader yields a DataReader for one or multiple result sets, ExecuteScalar returns the first column of the first row (like COUNT, SUM, or new identity via OUTPUT or SCOPE_IDENTITY()), and ExecuteNonQuery executes data manipulation statements such as INSERT, UPDATE, DELETE, and DDL, returning the number of affected rows.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.