JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Overview of ADO.NET Objects

Here's a list of the most common ADO.NET objects:

  • Data connection objects—To start working with a database, you must have a data connection. A data adapter needs a connection to a data source to read and write data, and it uses OleDbConnection or SqlConnection objects to communicate with a data source.

  • Data adapters—Data adapters are a very important part of ADO.NET. You use them to communicate between a data source and a dataset. You typically configure a data adapter with SQL to execute against the data source. The two types of data adapters are OleDbDataAdapter and SqlDataAdapter objects.

  • Command objects—Data adapters can read, add, update, and delete records in a data source. To allow you to specify how each of these operations work, a data adapter contains command objects for each of them. Data adapters support four properties that give you access to these command objects: SelectCommand, InsertCommand, UpdateCommand, and DeleteCommand.

  • Datasets—Datasets store data in a disconnected cache. The structure of a dataset is similar to that of a relational database; it gives you access to an object model of tables, rows, and columns, and it contains constraints and relationships defined for the dataset. Datasets are supported with DataSet objects.

  • DataTable objectsDataTable objects hold a data table from a data source. Data tables contain two important properties: Columns, which is a collection of the DataColumn objects that represent the columns of data in a table, and Rows, which is a collection of DataRow objects, representing the rows of data in a table.

  • Data readersDataReader objects hold a read-only, forward-only (i.e., you can only move from one record to the succeeding record, not backwards) set of data from a database. Using a data reader can increase speed because only one row of data is in memory at a time. See "Using a Data Reader" in Chapter 22

  • Data views—Data views represent a customized view of a single table that can be filtered, searched, or sorted. In other words, a data view, supported by the DataView class, is a data "snapshot" that takes up few resources. See "Using Data Views" in this chapter.

  • Constraint objects—Datasets support constraints to check data integrity. A constraint, supported by the Constraint class, is a rule that can be used when rows are inserted, updated, or deleted to check the affected table after the operation. There are two types of constraints: unique constraints check that the new values in a column are unique throughout the table, and foreign-key constraints specify how related records should be updated when a record in another table is updated.

  • DataRelation objectsDataRelation objects specify a relationship between parent and child tables, based on a key that both tables share. See "Using Master/Detail Relationships and Data Relation Objects" in Chapter 21.

  • DataRow objectsDataRow objects correspond to a particular row in a data table. You use the Item property to get or set a value in a particular field in the row. See "Creating Data Rows in Code" in Chapter 22.

  • DataColumn objectsDataColumn objects correspond to the columns in a table. Each object has a DataType property that specifies the kind of data each column contains, such as integers or string values. See "Creating Data Columns in Code" in Chapter 22.

We'll put these objects to work in this and the next several chapters. In fact, it's time to turn to the Immediate Solutions section now to start working with specific details of ADO.NET.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor