BackgroundWorker and closing an OleDbConnection

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
 
R

rowe_newsgroups

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
 
E

eforden

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
 
R

rowe_newsgroups

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

Thanks,

Seth Rowe
 
E

eforden

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

--Eric
 
C

Cor Ligthert [MVP]

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]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top