DataSet.Clear Método
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Limpa o DataSet de todos os dados, removendo todas as linhas em todas as tabelas.
public:
void Clear();
public void Clear ();
member this.Clear : unit -> unit
Public Sub Clear ()
O exemplo a seguir limpa o DataSet de todas as linhas em todas as tabelas.
private void ClearDataSet(DataSet dataSet)
{
// To test, print the number rows in each table.
foreach(DataTable table in dataSet.Tables)
{
Console.WriteLine(table.TableName + "Rows.Count = "
+ table.Rows.Count.ToString());
}
// Clear all rows of each table.
dataSet.Clear();
// Print the number of rows again.
foreach(DataTable table in dataSet.Tables)
{
Console.WriteLine(table.TableName + "Rows.Count = "
+ table.Rows.Count.ToString());
}
}
Private Sub ClearDataSet(ByVal dataSet As DataSet)
' To test, print the number rows in each table.
Dim table As DataTable
For Each table In dataSet.Tables
Console.WriteLine(table.TableName & "Rows.Count = " _
& table.Rows.Count.ToString())
Next
' Clear all rows of each table.
dataSet.Clear()
' Print the number of rows again.
For Each table In dataSet.Tables
Console.WriteLine(table.TableName & "Rows.Count = " _
& table.Rows.Count.ToString())
Next
End Sub
Se o DataSet estiver associado a um XmlDataDocument, chamar DataSet.Clear ou DataTable.Clear gerará o NotSupportedException. Para evitar essa situação, percorra cada tabela, removendo cada linha uma de cada vez.
Produto | Versões |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: