In Brief

Here's an overview of this chapter's topics:

  • Connection objects support the connections to data sources in ADO.NET. You need a connection object, such as an OleDbConnection , SqlConnection , OdbcConnection or OracleConnection object, to connect to a database.

  • When you have a connection object, you can use that object's Open method to open the connection, and assign the object to the Connection property of a command object. You store the SQL you want to execute in command objects, and you can create command objects that will select data from the data source, insert new records, delete records, and update the database. Each command object has a connection object associated with it.

  • You use command objects with data adapter objects. Data adapters are responsible for handling your connection to a data source, and you can assign command objects to a data adapter object's SelectCommand , DeleteCommand , UpdateCommand , and InsertCommand properties. If just you want the data adapter to fetch data, you only need to use SelectCommand .

  • Once you have a data adapter object, you can use its Fill method to fill a dataset object with data.

  • You can use DataTable objects to create data tables in datasets (you can add the tables to a dataset with the Add method of the dataset object's Tables collection). You pass the name of the table to the DataTable object's constructor and use DataColumn objects to configure the fields in each record.

  • When you create a data column, you pass the name of the new field to the DataColumn constructor, and set the data type of the field with the DataColumn object's DataType property. You can add the new column to a DataTable object's Columns collection using the Add method.

  • To create the records in the new table, you use DataRow objects. You can create new rows with all the fields presently in the table using the table object's NewRow method. You can add the new row to a DataTable object's Rows collection using the Add method.

  • You can use a DataRow object to access the value in a field in a row like this: row1["au_fname"] or row1[2] .



Microsoft Visual C#. NET 2003 Kick Start
Microsoft Visual C#.NET 2003 Kick Start
ISBN: 0672325470
EAN: 2147483647
Year: 2002
Pages: 181

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net