BackgroundWorker and closing an OleDbConnection

  • Thread starter Thread starter eforden
  • Start date Start date
E

eforden

Hi,

I am new at using the BackgroundWorker so please forgive me if this topic
has already been covered.

I'm using BackgroundWorker to import data into an Access 2000 database using
OleDbConnection. After the thread is complete, I'm noticing that the Access
..ldb lock file still remains, and does not disappear until I close all the
way out of my program. Since the call to Open the OleDbConnection is inside
of the thread (in the DoWork function) how can I force the OleDbConnection
to Close so I can rename my .mdb file?

TIA!!

--Eric
 
Why not just call .Close() or .Dispose on the connection object in the
thread? I believe you can use the "using" block to do this same thing
(it's only in VS2005 though)

Thanks,

Seth Rowe
 
Hi Seth,

I should have specified that I am using VS2005, and already do have my
connection setup in a Using block - that's why I'm kinda stumped why it
isn't releasing the resource.

I've tried .Close and .Dispose, they don't appear to have any effect.

Any other ideas?

Thanks!!

--Eric
 
Just a long shot, have you tried adding GC.Collect() to the end of the
routine?

Thanks,

Seth Rowe
 
Well that long shot definitely solved my issue, thank you so much for that
tip!!

--Eric
 
Eric,

Be aware that a thread is normally not direct automaticly destructed if it
ends. Doing that can be very inefficient, so take care what you are doing.

Cor


"eforden" <eforden_nospam@proserve-solutions_nospam.com> schreef in beric

ht news:[email protected]...
 
Back
Top