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

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.
 
M

Marina Levit [MVP]

You would have to mark each row for deletion. Clearing the dataset
physically removes all the rows.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top