In this chapter you saw the connected side of ADO.NET. The connected classes are based on the data providers. There are a number of data providers. Some of them are Sql, OleDb, and Odbc. As their names suggest, they're designed to work with a specific kind of data source. For example, the Sql data providers are designed to work with SQL Server databases, and the OleDb data providers are designed to work with OLE DB data sources. Similarly, you can use the Odbc data providers to work with any ODBC data source. Each of these data providers is best used with the associated data source. Although their names are different, all data providers work in same way.

All the data providers follow a common model. A connection is created between the data provider and the data sources. You saw how to access different kinds of data sources using different kinds of data providers. After a connection is created, a DataAdapter or a command accesses and updates the data source. A DataTable represents an in-memory cache for a database table. A DataSet is a collection of DataTables. A DataAdapter sits between a DataSet, and a data source and passes data back and forth. The Fill method of a DataAdapter fills data from a data source to a DataSet based on the SQL statement on which it was created. The Update method of a DataAdapter reflects DataSet changes to the data source. You can use commands to execute SQL statements. You can execute direct SQL commands such as INSERT, UPDATE, and DELETE to add, update, and delete data.

A DataReader is another important component used to read data from a data source through a DataAdapter. You can use the ExecuteReader method of a Command to get data in a DataReader. You can also execute stored procedures and views using a command. You also learned how to handle concurrency and locking issues using transactions in ADO.NET.

In the next chapter you'll concentrate on event handling in ADO.NET.

Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214 © 2008-2017.
If you may any questions please contact us: