Add Method (DataRow)
Collapse the table of content
Expand the table of content

DataRowCollection::Add Method (DataRow^)

 

Adds the specified DataRow to the DataRowCollection object.

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

public:
void Add(
	DataRow^ row
)

Parameters

row
Type: System.Data::DataRow^

The DataRow to add.

Exception Condition
ArgumentNullException

The row is null.

ArgumentException

The row either belongs to another table or already belongs to this table.

ConstraintException

The addition invalidates a constraint.

NoNullAllowedException

The addition tries to put a null in a DataColumn where AllowDBNull is false.

To create a new DataRow, you must use the NewRow method of the DataTable class. When you use the NewRow method, a new DataRow object is returned using the schema of parent DataTable. After you create the DataRow object and set the values for each of its columns, use the Add method to add the object to the collection.

Generates an exception if the user generates an exception in the RowChanging event. If an exception occurs, the row is not added to the table.

The following example uses the Add method to add a new DataRow to a DataRowCollection object.

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

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft