Chapter 3. Querying and Retrieving Data

3.0. Introduction

ADO.NET has both connected and disconnected classes. Disconnected classes let you access and manipulate offline the data you retrieved using the connected classes and later synchronize it with the underlying data source using the connected classes. The disconnected classes include the DataSet, DataTable, DataColumn, DataRow, DataView, DataRelation, and Constraint classes. The disconnected classes are part of the ADO.NET classes in the .NET Framework. Connected classes let you retrieve and update data in underlying data sources. These classes include the Connection, Command, DataReader, and DataAdapter classes. Each data provider is responsible for implementing the connected classes. The recipes in this chapter discuss creating, working with, and managing the ADO.NET connected objects—this includes executing queries, retrieving results, and retrieving and navigating results sets.

A Connection object is a unique session with the data source. A Connection specifies necessary authentication information needed to connect to a data source. The Connection object is specific to the type of data source—for example, the .NET Framework data provider for SQL Server includes the SqlConnection class.

A Command executes SQL statements and stored procedures against the data source using an established Connection. The CommandText property of the Command class contains the SQL statement executed against the data source. The Command object is ...

Get ADO.NET 3.5 Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.