By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Deleting 100,000 rows

P: n/a
I need to delete ALL rows in a dataset and currently use the method in the
code snippet below, which works fine. However, there can be 100,000 rows,
which makes the FILL, DR.Delete and UPDATE take a very long time.

Is there a way to simply delete the entire dataset and then update that to
the datasource more effectinely?

Thanks!
Bob Day

' FILL from datasource to dataset (not shown)
' Used to iterate through Details Row Collection

Dim DR As DS_Methods_Base.Methods_DetailsRow

' Iterate through the rows colleciton, Delete each rows in DataSet

For Each DR In gmCD.DS_Methods.Methods_Details.Rows

DR.Delete()

Next

' UPDATE from dataset to datasource (not shown)
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bob,

Deleteing from a datatable is extremely slow in this version of Net (It
thought that it has the attention).

Therefore clearing the datatable. "Datatable.Clear" and filling again will
probably giving you the best results.

I never did that, however you can in my opinion of course as well in this
case dispose your dataset and just create a new one (mydataset = new
dataset) and set that again to your datasource (be aware of that because in
this case the datasource will have a null reference when you don't do that).

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Bob Day wrote:
I need to delete ALL rows in a dataset and currently use the method in the
code snippet below, which works fine. However, there can be 100,000 rows,
which makes the FILL, DR.Delete and UPDATE take a very long time.

Is there a way to simply delete the entire dataset and then update that to
the datasource more effectinely?

Thanks!
Bob Day

' FILL from datasource to dataset (not shown)
' Used to iterate through Details Row Collection

Dim DR As DS_Methods_Base.Methods_DetailsRow

' Iterate through the rows colleciton, Delete each rows in DataSet

For Each DR In gmCD.DS_Methods.Methods_Details.Rows

DR.Delete()

Next

' UPDATE from dataset to datasource (not shown)


Are you getting the dataset via a SQL command? If so, just use SQL to
delete the entries you want. i.e.:

sqlCommand="delete from mytable"
This will erase all rows from mytable. Ofcourse you can add a WHERE
statement to further narrow the set you wish to delete.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #3

P: n/a
Yes, the SQL approach is best.

Thanks!

Bob Day
-
"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:ef**************@TK2MSFTNGP14.phx.gbl...
I need to delete ALL rows in a dataset and currently use the method in the
code snippet below, which works fine. However, there can be 100,000 rows,
which makes the FILL, DR.Delete and UPDATE take a very long time.

Is there a way to simply delete the entire dataset and then update that to
the datasource more effectinely?

Thanks!
Bob Day

' FILL from datasource to dataset (not shown)
' Used to iterate through Details Row Collection

Dim DR As DS_Methods_Base.Methods_DetailsRow

' Iterate through the rows colleciton, Delete each rows in DataSet

For Each DR In gmCD.DS_Methods.Methods_Details.Rows

DR.Delete()

Next

' UPDATE from dataset to datasource (not shown)

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.