DataTable.Clear Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Efface toutes DataTable les données.
public:
void Clear();
public void Clear();
member this.Clear : unit -> unit
Public Sub Clear ()
Exemples
L’exemple suivant efface la table de toutes les données.
private void ClearTable(DataTable table)
{
try
{
table.Clear();
}
catch (DataException e)
{
// Process exception and return.
Console.WriteLine("Exception of type {0} occurred.",
e.GetType());
}
}
Private Sub ClearTable(table As DataTable)
Try
table.Clear()
Catch e As DataException
' Process exception and return.
Console.WriteLine("Exception of type {0} occurred.", _
e.GetType().ToString())
End Try
End Sub
Remarques
Toutes les lignes de toutes les tables sont supprimées. Une exception est générée si la table a des relations enfants appliquées qui entraîneraient l’orphelin des lignes enfants.
Si l’objet DataSet est lié à un XmlDataDocumentappel ou DataSet.ClearDataTable.Clear déclenche le NotSupportedException. Pour éviter cette situation, parcourez chaque table, en supprimant chaque ligne une à la fois. Lorsque vous utilisez NewRow pour créer des lignes, les lignes doivent être traitées avant d’appeler Clear.