DataRowCollection::Add Method (array<Object^>^)

 

Creates a row using specified values and adds it to the DataRowCollection.

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

public:
DataRow^ Add(
	... array<Object^>^ values
)

Parameters

values
Type: array<System::Object^>^

The array of values that are used to create the new row.

Return Value

Type: System.Data::DataRow^

None.

Exception Condition
ArgumentException

The array is larger than the number of columns in the table.

InvalidCastException

A value does not match its respective column type.

ConstraintException

Adding the row invalidates a constraint.

NoNullAllowedException

Trying to put a null in a column where AllowDBNull is false.

If a DataColumn object has its AutoIncrement set to True, null should be passed to get the default value for that column.

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

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

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

.NET Framework
Available since 1.1
Return to top
Show: