DataSet::Load Method (IDataReader^, LoadOption, array<DataTable^>^)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Fills a DataSet with values from a data source using the supplied IDataReader, using an array of DataTable instances to supply the schema and namespace information.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

void Load(
	IDataReader^ reader,
	LoadOption loadOption,
	... array<DataTable^>^ tables


Type: System.Data::IDataReader^

An IDataReader that provides one or more result sets.

Type: System.Data::LoadOption

A value from the LoadOption enumeration that indicates how rows already in the DataTable instances within the DataSet will be combined with incoming rows that share the same primary key.

Type: array<System.Data::DataTable^>^

An array of DataTable instances, from which the Load method retrieves name and namespace information. Each of these tables must be a member of the DataTableCollection contained by this DataSet.

The Load method provides a technique for filling a single DataTable with data, retrieved from an IDataReader instance. This method provides the same functionality, but allows you to load multiple result sets from an IDataReader into multiple tables within a DataSet.


The load operation will fail with an InvalidOperationException if any of the source data columns in the incoming reader are computed columns.

The loadOption parameter allows you to specify how you want the imported data to interact with existing data, and can be any of the values from the LoadOption enumeration. See the documentation for the DataTableLoad method for more information on using this parameter.

The tables parameter allows you to specify an array of DataTable instances, indicating the order of the tables corresponding to each result set loaded from the reader. The Loadmethod fills each supplied DataTable instance with data from a single result set from the source data reader. After each result set, the Loadmethod moves on to the next result set within the reader, until there are no more result sets.

The name resolution scheme for this method is the same as that followed by the Fill method of the DbDataAdapter class.

The following example creates a new DataSet, adds two DataTable instances to the DataSet, and then fills the DataSet using the Load method, retrieving data from a DataTableReader that contains two result sets. Finally, the example displays the contents of the tables in the console window.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top