This documentation is archived and is not being maintained.

DataTable.LoadDataRow Method (Object[], LoadOption)

Finds and updates a specific row. If no matching row is found, a new row is created using the given values.

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

public DataRow LoadDataRow (
	Object[] values,
	LoadOption loadOption
public DataRow LoadDataRow (
	Object[] values, 
	LoadOption loadOption
public function LoadDataRow (
	values : Object[], 
	loadOption : LoadOption
) : DataRow
Not applicable.



An array of values used to create the new row.


Used to determine how the array values are applied to the corresponding values in an existing row.

Return Value

The new DataRow.

The LoadDataRow method takes an array of values and finds the matching value(s) in the primary key column(s).

If a column has a default value, pass a null value in the array to set the default value for that column. Similarly, if a column has its AutoIncrement property set to true, pass a null value in the array to set the automatically generated value for the row.

The value of the loadOption parameter is used to determine how the values in the array are applied to an existing row. For example, if loadOption is set to OverwriteChanges, the Original and Current values of each column are replaced with the values in the incoming row and the RowState property is set to Unchanged.

Exceptions can also occur during either a ColumnChanging or RowChanging event. If an exception occurs, the row is not added to the table.

Use LoadDataRow in conjunction with BeginLoadData and EndLoadData.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0