Core objects and the connected model — ADO.NET

Lesson 1 of 9 in the free ADO.NET — Connected & Disconnected Data Access course on DevLadder.

Use ordinal getters (GetInt32(0)) or cache reader.GetOrdinal("Name") for speed; check reader.IsDBNull(i) before reading nullable columns.

ADO.NET is .NET's core data access library (System.Data + provider packages). Main objects: Connection (connects to the DB), Command (executes SQL/procs), Parameter, DataReader (forward-only fast read), DataAdapter (fills/updates DataSets), DataSet/DataTable (in-memory data), Transaction. For SQL Server use Microsoft.Data.SqlClient (SqlConnection, SqlCommand…).

Connected: the connection stays open while you read with a DataReader — forward-only, read-only, very fast, minimal memory. Disconnected: a DataAdapter fills a DataSet/DataTable, then closes the connection; you can navigate, edit and later push changes back with Update() — more memory, more flexibility. Modern apps mostly use the connected model (directly or via Dapper/EF).

Source: DEV - interview — Read the full article on the original site ↗

By Admin