DataSet Toolkit Overview
In order to fill a DataSet, you will need to initialize both a CommandBuilder, and
an instance of the MultiTableDataAdapter. Unlike the DataAdapter type supplied by
the Microsoft® .NET Framework, the MultiTableDataAdapter works for as many tables
as you like, and you never need to supply a Select command. The MultiTableDataAdapter
utilizes the CommandBuilder to generate Select statements, and these statements
can either be tailored by use of WhereConstraint objects, or by use of custom SQL commands
when necessary.
You do not need to specify the MultiTableDataAdapter to the CommandBuilder when it
is created, but it must be registered with the CommandBuilder before any Fill or
Update operation. The CommandBuilder supplies the commands to the MultiTableDataAdapter
when a fill or update is requested. When you register a MultiTableDataAdapter with
a CommandBuilder, that builder subscribes to the Filling and Updating events of
the given MultiTableDataAdapter.
Once you have created a MultiTableDataAdapter and registered it with a CommandBuilder,
you can simply call any one of the Fill operations on the MultiTableDataAdapter.
You pass in whichever data structure you wish to fill. It doesn't matter if you
pass in one row, or the whole DataSet, it will be automatically filled for you.
If the underlying database has relationships and primary keys, these should be enforced
on the DataSet as well so that the MultiTableDataAdapter can fill tables in the
correct order. However, if you disable constraint checking on the DataSet, and have
no constraints that require unique values, there is no requirement for constraints
enforced by the Fill operations.
Because the MultiTableDataAdapter infers the underlying database schema from the
data structures you supply to its operations, it will be as 'smart' as the information
you provide. A fully configured DataSet will allow you to rely fully on the MultiTableDataAdapter
for properly ordered table loading, and proper cascading of updates and deletes.
Please see the full documentation for the usage details.
.Net 2.0 Example [c#]
.Net 1.1 Example [c#]
|