Uredi

Deli z drugimi prek


DataAdapter.Fill Method

Definition

Adds or refreshes rows in the DataSet to match those in the data source.

Overloads

Fill(DataSet)

Adds or refreshes rows in the DataSet to match those in the data source.

Fill(DataTable, IDataReader)

Adds or refreshes rows in the DataTable to match those in the data source using the DataTable name and the specified IDataReader.

Fill(DataTable[], IDataReader, Int32, Int32)

Adds or refreshes rows in a specified range in the collection of DataTable objects to match those in the data source.

Fill(DataSet, String, IDataReader, Int32, Int32)

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.

Fill(DataSet)

Source:
DataAdapter.cs
Source:
DataAdapter.cs
Source:
DataAdapter.cs

Adds or refreshes rows in the DataSet to match those in the data source.

public:
 virtual int Fill(System::Data::DataSet ^ dataSet);
public:
 abstract int Fill(System::Data::DataSet ^ dataSet);
public virtual int Fill (System.Data.DataSet dataSet);
public abstract int Fill (System.Data.DataSet dataSet);
abstract member Fill : System.Data.DataSet -> int
override this.Fill : System.Data.DataSet -> int
abstract member Fill : System.Data.DataSet -> int
Public Overridable Function Fill (dataSet As DataSet) As Integer
Public MustOverride Function Fill (dataSet As DataSet) As Integer

Parameters

dataSet
DataSet

A DataSet to fill with records and, if necessary, schema.

Returns

The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows.

Implements

Remarks

The Fill method retrieves rows from the data source using the SELECT statement specified by an associated SelectCommand property. The connection object associated with the SELECT statement must be valid, but it does not need to be open. If the connection is closed before Fill is called, it is opened to retrieve data, then closed. If the connection is open before Fill is called, it remains open.

The Fill operation then adds the rows to destination DataTable objects in the DataSet, creating the DataTable objects if they do not already exist. When creating DataTable objects, the Fill operation normally creates only column name metadata. However, if the MissingSchemaAction property is set to AddWithKey, appropriate primary keys and constraints are also created.

If the SelectCommand returns the results of an OUTER JOIN, the DataAdapter does not set a PrimaryKey value for the resulting DataTable. You must explicitly define the primary key to ensure that duplicate rows are resolved correctly. For more information, see Defining Primary Keys.

If the data adapter encounters duplicate columns while populating a DataTable, it generates names for the subsequent columns, using the pattern "columnname1", "columnname2", "columnname3", and so on. If the incoming data contains unnamed columns, they are placed in the DataSet according to the pattern "Column1", "Column2", and so on. When multiple result sets are added to the DataSet each result set is placed in a separate table. Additional result sets are named by appending integral values to the specified table name (for example, "Table", "Table1", "Table2", and so on). Applications using column and table names should ensure that conflicts with these naming patterns does not occur.

When the SELECT statement used to populate the DataSet returns multiple results, such as a batch SQL statements, if one of the results contains an error, all subsequent results are skipped and not added to the DataSet.

You can use the Fill method multiple times on the same DataTable. If a primary key exists, incoming rows are merged with matching rows that already exist. If no primary key exists, incoming rows are appended to the DataTable.

Note

When handling batch SQL statements that return multiple results, the implementation of FillSchema for the .NET Framework Data Provider for OLE DB retrieves schema information for only the first result. To retrieve schema information for multiple results, use Fill with the MissingSchemaAction set to AddWithKey.

See also

Applies to

Fill(DataTable, IDataReader)

Source:
DataAdapter.cs
Source:
DataAdapter.cs
Source:
DataAdapter.cs

Adds or refreshes rows in the DataTable to match those in the data source using the DataTable name and the specified IDataReader.

protected:
 virtual int Fill(System::Data::DataTable ^ dataTable, System::Data::IDataReader ^ dataReader);
protected virtual int Fill (System.Data.DataTable dataTable, System.Data.IDataReader dataReader);
abstract member Fill : System.Data.DataTable * System.Data.IDataReader -> int
override this.Fill : System.Data.DataTable * System.Data.IDataReader -> int
Protected Overridable Function Fill (dataTable As DataTable, dataReader As IDataReader) As Integer

Parameters

dataTable
DataTable

A DataTable to fill with records.

dataReader
IDataReader

An instance of IDataReader.

Returns

The number of rows successfully added to or refreshed in the DataTable. This does not include rows affected by statements that do not return rows.

Remarks

See the remarks for DataAdapter.Fill(DataSet) for additional information.

See also

Applies to

Fill(DataTable[], IDataReader, Int32, Int32)

Source:
DataAdapter.cs
Source:
DataAdapter.cs
Source:
DataAdapter.cs

Adds or refreshes rows in a specified range in the collection of DataTable objects to match those in the data source.

protected:
 virtual int Fill(cli::array <System::Data::DataTable ^> ^ dataTables, System::Data::IDataReader ^ dataReader, int startRecord, int maxRecords);
protected virtual int Fill (System.Data.DataTable[] dataTables, System.Data.IDataReader dataReader, int startRecord, int maxRecords);
abstract member Fill : System.Data.DataTable[] * System.Data.IDataReader * int * int -> int
override this.Fill : System.Data.DataTable[] * System.Data.IDataReader * int * int -> int
Protected Overridable Function Fill (dataTables As DataTable(), dataReader As IDataReader, startRecord As Integer, maxRecords As Integer) As Integer

Parameters

dataTables
DataTable[]

A collection of DataTable objects to fill with records.

dataReader
IDataReader

An instance of IDataReader.

startRecord
Int32

The zero-based index of the starting record.

maxRecords
Int32

An integer indicating the maximum number of records.

Returns

The number of rows successfully added to or refreshed in the DataTable. This does not include rows affected by statements that do not return rows.

Remarks

See the remarks for System.Data.Common.DataAdapter.Fill(System.Data.DataSet) for additional information.

See also

Applies to

Fill(DataSet, String, IDataReader, Int32, Int32)

Source:
DataAdapter.cs
Source:
DataAdapter.cs
Source:
DataAdapter.cs

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.

protected:
 virtual int Fill(System::Data::DataSet ^ dataSet, System::String ^ srcTable, System::Data::IDataReader ^ dataReader, int startRecord, int maxRecords);
protected virtual int Fill (System.Data.DataSet dataSet, string srcTable, System.Data.IDataReader dataReader, int startRecord, int maxRecords);
abstract member Fill : System.Data.DataSet * string * System.Data.IDataReader * int * int -> int
override this.Fill : System.Data.DataSet * string * System.Data.IDataReader * int * int -> int
Protected Overridable Function Fill (dataSet As DataSet, srcTable As String, dataReader As IDataReader, startRecord As Integer, maxRecords As Integer) As Integer

Parameters

dataSet
DataSet

A DataSet to fill with records.

srcTable
String

A string indicating the name of the source table.

dataReader
IDataReader

An instance of IDataReader.

startRecord
Int32

The zero-based index of the starting record.

maxRecords
Int32

An integer indicating the maximum number of records.

Returns

The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows.

Remarks

See the remarks for System.Data.Common.DataAdapter.Fill(System.Data.DataSet) for additional information.

See also

Applies to