Export (0) Print
Expand All

DataRowCollection.Clear Method

Clears the collection of all rows.

[Visual Basic]
Public Sub Clear()
[C#]
public void Clear();
[C++]
public: void Clear();
[JScript]
public function Clear();

Exceptions

Exception Type Condition
InvalidConstraintException A ForeignKeyConstraint is enforced on the DataRowCollection.

Example

[Visual Basic, C#, C++] The following example clears a DataRowCollection of all items.

[Visual Basic] 
Private Sub ClearTable(ByVal myTable As DataTable)
    Dim rc As DataRowCollection
    rc = myTable.Rows
    ' Clear all rows.
    rc.Clear
 End Sub

[C#] 
private void ClearTable(DataTable myTable){
    DataRowCollection rc; 
    rc = myTable.Rows;
    // Clear all rows.
    rc.Clear();
 }

[C++] 
private:
void ClearTable(DataTable* myTable){
    DataRowCollection* rc; 
    rc = myTable->Rows;
    // Clear all rows.
    rc->Clear();
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataRowCollection Class | DataRowCollection Members | System.Data Namespace | Add | Remove

Show:
© 2014 Microsoft