Using Dataset.Clear() to clear an SQL-database

  • Thread starter Thread starter Cub71
  • Start date Start date
C

Cub71

Is it possible to use

dataset.Clear();
dataAdapterSomething.Update(dataset.table);

to clear a table in an SQL database?

I am not able to get this to work. The dataset clears, but the changes
are not updated into the database.
 
You would have to mark each row for deletion. Clearing the dataset
physically removes all the rows.
 
Just use a SqlCommand to run either
Delete From TableName
if the table is referenced by foreign key constraints.
If it isnt:
Truncate Table TableName

Truncate also resets Identity columns whereas delete doesnt.

Ciaran O'Donnell
 
Back
Top