This documentation is archived and is not being maintained.

DataTable::ImportRow Method

Copies a DataRow into a DataTable, preserving any property settings, as well as original and current values.

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

public:
void ImportRow(
	DataRow^ row
)

Parameters

row
Type: System.Data::DataRow
The DataRow to be imported.

Calling NewRow adds a row to the table using the existing table schema, but with default values for the row, and sets the DataRowState to Detached. Calling ImportRow preserves the existing DataRowState along with other values in the row. If the DataRow that is passed as a parameter is in a detached state, it is ignored, and no exception is thrown.

The new row will be added to the end of the data table.

If the new row violates a Constraint it won’t be added to the data table.

You can get the index of the new row with as DataTable.Rows.Find and DataTable.Rows.IndexOf. See DataRowCollection and Rows for more information.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: