PC Review


Reply
Thread Tools Rate Thread

Deleting 100,000 rows

 
 
Bob Day
Guest
Posts: n/a
 
      1st Apr 2005
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)


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      4th Apr 2005
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


 
Reply With Quote
 
C-Services Holland b.v.
Guest
Posts: n/a
 
      4th Apr 2005
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.
 
Reply With Quote
 
Bob Day
Guest
Posts: n/a
 
      5th Apr 2005
Yes, the SQL approach is best.

Thanks!

Bob Day
-
"Bob Day" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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)
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting blank rows for up to 60000 rows of data gbpg Microsoft Excel Programming 3 27th Dec 2009 08:37 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Programming 2 13th Nov 2008 01:32 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Worksheet Functions 1 12th Nov 2008 01:39 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Microsoft Excel Discussion 1 12th Nov 2008 01:32 PM
Excel 2000 VBA Deleting Rows when certain text in rows exists scain2004 Microsoft Excel New Users 1 15th Mar 2004 02:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.