Results 1 to 3 of 3

Thread: DataTable clear or dispose?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Location
    Bucharest - Romania
    Posts
    5

    DataTable clear or dispose?

    Hello all,

    I want to understand a situation; it's related to datatable clear().
    I have a code that populate a typed datatable from Excel in a separate thread using a backgroundworker. This works well, the table is filled and I can see the data. Now, I want to clear the data from table and restart the import. The operation is ten times slower than the first time. My datatable variable is declared like this:

    Private dt as new DataTable - not a local variable

    I want that all subs from class to be able to use the table, that's the reason I declared the table as private.
    What I want is to be able to create a new instance of dt (or clear allocated memory) - maybe this is the reason for slowdown. But I don't know how to do this. Please advice.

    Thanks,
    Costin
    If you don't help, why are you still expecting others to help you?

  2. #2
    New Member
    Join Date
    Oct 2011
    Posts
    1

    Re: DataTable clear or dispose?

    I'm encountering the same issue. Did you ever find a solution?

    Thanks.
    -Chris

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: DataTable clear or dispose?

    Start a new thread on it. Clearing the table should be faster than disposing, though only marginally, so. That isn't the problem, though, as it will take an unnoticeable fraction of a second either way. Something else is happening for the slow second read.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width