Adds a DataRow to the DataRowCollection.
Adds the specified DataRow to the DataRowCollection object.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub Add(DataRow)
[C#] public void Add(DataRow);
[C++] public: void Add(DataRow*);
[JScript] public function Add(DataRow);
Creates a row using specified values and adds it to the DataRowCollection.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Overridable Function Add(Object()) As DataRow
[C#] public virtual DataRow Add(object[]);
[C++] public: virtual DataRow* Add(Object*[]);
[JScript] public function Add(Object[]) : DataRow;
[Visual Basic, C#] The following example uses the Add method to create and add a new DataRow object to a DataRowCollection.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Add. For other examples that might be available, see the individual overload topics.
[Visual Basic] Private Sub AddRow(ByVal myTable As DataTable) Dim rc As DataRowCollection Dim myNewRow As DataRow ' Create an array with three elements. Dim rowVals(2) As Object rc = myTable.Rows rowVals(0) = "hello" rowVals(1) = "world" rowVals(2) = "two" ' Add and return the new row. myNewRow = rc.Add(rowVals) End Sub [C#] private void AddRow(DataTable myTable){ DataRowCollection rc; DataRow myNewRow; // Create an array with three elements. object[] rowVals = new object[3]; rc = myTable.Rows; rowVals[0] = "hello"; rowVals[1] = "world"; rowVals[2] = "two"; // Add and return the new row. myNewRow = rc.Add(rowVals); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
DataRowCollection Class | DataRowCollection Members | System.Data Namespace