Deleting ALL rows

  • Thread starter Thread starter Brad Allison
  • Start date Start date
B

Brad Allison

I have a table where the user stores recent search words used. There is
occassion where this table needs to be cleared and deleted of all data. Is
there an easy way to just take the dataset, mark all rows as deleted and
then use the data adapters Update?

Thanks for the information.

Brad
 
Hi Brad,

DataRow collection, which keeps all the rows in a datatable does not have
any method, which would allow to mark all the rows as a deleted without
looping. I think best way in your case is to execute DELETE SQL statement
against database and just dispose DataSet locally or call Clear method to
delete all the rows
 
Hi Brad,

this is possible, but highly inefficient if I understand correctly what you
intend to do. If you just want to delete all keywords in the table (or just
the ones of a particular user) it would be much faster to just issue a
single delete statement against the DB (such as DELETE FROM keywords or
DELETE FROM keywords WHERE user='xxx').

If you use the dataadapter then this will translate to several (however many
rows you are deleting) delete statements to be executed against the RDBMS.

Hope this helped
Mirko
 
Hi Brad,

I assume this is an sql server table. Why not just run a stored proc that
calls 'truncate swordtable'.

HTH,

Bernie Yaeger
 
The framework extensions libraries I have developed have an extended dataset
which supports deletion of multiple rows by criteria (which may be blank)
with a single command.

Fully documented. Requires .NET framework 1.1 or later.

You will be allowed to use the libraries in any application - private or
commercial, and distribute them as part of your application, royalty-free.

E-mail me for your free copy: (e-mail address removed)
Your acceptance of the license agreement will be required.

Ori
 
Bernie,

This is actually an Access table. I would be able to run a DELETE * FROM
statement I think. I have not tried it yet, but I will later.

Thanks for the information.

Brad
 
Yes, but it is not very friendly. When you fire Update, you loop through
each record. It is much better to create a destruct stored procedure or fire
"DELETE FROM TableName" at the database than to incur the overhead of the
loop.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
You can run a DELETE FROM and kill all of the data quite easily. I believe
Access has a TRUNCATE function (name?) as well.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Back
Top