Freigeben über


DataRowCollection.Clear-Methode

Löscht alle Zeilen aus der Auflistung.

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

Syntax

'Declaration
Public Sub Clear
'Usage
Dim instance As DataRowCollection

instance.Clear
public void Clear ()
public:
void Clear ()
public void Clear ()
public function Clear ()

Ausnahmen

Ausnahmetyp Bedingung

InvalidConstraintException

Eine ForeignKeyConstraint wird für die DataRowCollection erzwungen.

Beispiel

Im folgenden Beispiel werden alle Elemente aus einer DataRowCollection gelöscht.

Private Sub AddRow(ByVal table As DataTable)
    ' Create an array with three elements.
    Dim rowVals(2) As Object
    Dim rowCollection As DataRowCollection = table.Rows
    rowVals(0) = "hello"
    rowVals(1) = "world"
    rowVals(2) = "two"

    ' Add and return the new row.
    Dim row As DataRow = rowCollection.Add(rowVals) 
End Sub
private void AddRow(DataTable table)
{
    // Create an array with three elements.
    object[] rowVals = new object[3];
    DataRowCollection rowCollection = table.Rows;
    rowVals[0] = "hello";
    rowVals[1] = "world";
    rowVals[2] = "two";

    // Add and return the new row.
    DataRow row = rowCollection.Add(rowVals);
}

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

DataRowCollection-Klasse
DataRowCollection-Member
System.Data-Namespace
Add
Remove