Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET Database Programming Weekend Crash Course - J. Butler, T. Caudill.pdf
Скачиваний:
31
Добавлен:
24.05.2014
Размер:
3.32 Mб
Скачать

Session 20—Introducing DataSets, Part I

203

The DataSet’s Tables property, in this case, returns a collection of OleDbDataTable objects in the DataSet object. More on that in the next Session, “Introducing DataSets, Part II,” but in the meantime, if you want a list of the bands in the t_bands table, simply set the dgBands object’s DataMember property as follows:

dgBands.DataSource = oDA.dgBands.DataMember(“Band Information”)

Update method

The Update method calls the respective insert, update, or delete command for each inserted, updated, or deleted row in the DataSet. There are three different ways to call the Update method — you can pass:

An array of DataRow objects

A DataSet object

A DataSet object and a string representing a table name

If you make changes to any of the tables in your DataSet, you could use the following syntax to send the changes to the Music database:

oDA.Update(oDS, “t_bands”)

Dispose method

The Dispose method, when called, disposes of the DataAdapter object. That’s about all we’ll cover for the DataAdapter object.

Cross-Ref

The DataAdapter object has many more properties and methods that we didn’t cover in this discussion. For more details, refer to the .NET documentation.

Using DataSet Objects

As we mentioned before, a DataSet object is a memory-resident database that provides a consistent programming model regardless of the data source. A DataSet object represents a complete set of data including related tables, constraints, and relationships among the tables. The DataSet object is a very complex object and has numerous properties, methods, and collections. We’ll start our discussion of datasets with the properties.

DataSetName property

The DataSetName property is used to get or set the name of the DataSet object. This is fairly straightforward, as shown in the following example:

oDS.DataSetName = “MyDataSet”