473,654 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BackgroundWorke r and closing an OleDbConnection

Hi,

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

I'm using BackgroundWorke r 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

Jan 8 '07 #1
6 2740
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
eforden wrote:
Hi,

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

I'm using BackgroundWorke r 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
Jan 8 '07 #2
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

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ s34g2000cwa.goo glegroups.com.. .
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
eforden wrote:
>Hi,

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

I'm using BackgroundWorke r to import data into an Access 2000 database
using
OleDbConnectio n. 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
OleDbConnectio n
to Close so I can rename my .mdb file?

TIA!!

--Eric

Jan 8 '07 #3
Just a long shot, have you tried adding GC.Collect() to the end of the
routine?

Thanks,

Seth Rowe
eforden wrote:
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

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ s34g2000cwa.goo glegroups.com.. .
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
eforden wrote:
Hi,

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

I'm using BackgroundWorke r 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
Jan 8 '07 #4
Well that long shot definitely solved my issue, thank you so much for that
tip!!

--Eric
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ i15g2000cwa.goo glegroups.com.. .
Just a long shot, have you tried adding GC.Collect() to the end of the
routine?

Thanks,

Seth Rowe
eforden wrote:
>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

"rowe_newsgrou ps" <ro********@yah oo.comwrote in message
news:11******* *************** @s34g2000cwa.go oglegroups.com. ..
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
eforden wrote:
Hi,

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

I'm using BackgroundWorke r to import data into an Access 2000 database
using
OleDbConnectio n. 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
OleDbConnectio n
to Close so I can rename my .mdb file?

TIA!!

--Eric

Jan 8 '07 #5
Glad I could help!

Thanks,

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

--Eric
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ i15g2000cwa.goo glegroups.com.. .
Just a long shot, have you tried adding GC.Collect() to the end of the
routine?

Thanks,

Seth Rowe
eforden wrote:
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

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ s34g2000cwa.goo glegroups.com.. .
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
eforden wrote:
Hi,

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

I'm using BackgroundWorke r 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
Jan 9 '07 #6
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_nospa m.comschreef in beric

ht news:uN******** ******@TK2MSFTN GP04.phx.gbl...
Well that long shot definitely solved my issue, thank you so much for that
tip!!

--Eric
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ i15g2000cwa.goo glegroups.com.. .
>Just a long shot, have you tried adding GC.Collect() to the end of the
routine?

Thanks,

Seth Rowe
eforden wrote:
>>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

"rowe_newsgro ups" <ro********@yah oo.comwrote in message
news:11****** *************** *@s34g2000cwa.g ooglegroups.com ...
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
eforden wrote:
Hi,

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

I'm using BackgroundWorke r to import data into an Access 2000
database
using
OleDbConnecti on. 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
OleDbConnecti on
to Close so I can rename my .mdb file?

TIA!!

--Eric


Jan 9 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1963
by: Keith | last post by:
Hi, if have this method in a cs file that connections to a database and returns a datareader to my web form. public OleDbDataReader GetDataReader(string theSQL) { theConn = new OleDbConnection(ConnectionString); theConn.Open(); OleDbCommand cmd = new OleDbCommand(theSQL, theConn);
7
4124
by: Arsalan | last post by:
I have a function which return datareader Public Shared Function ReturnDReader(ByVal query As String) As OleDbDataReader Dim Connection_String As String = System.Configuration.ConfigurationSettings.AppSettings("strConn") Dim conn As OleDbConnection Dim cm As OleDbCommand Dim dr As OleDbDataReader Try
2
2895
by: Sagaert Johan | last post by:
Hi I have a problem with an mdb file still being locked after i closed the OleDBConnection. (can't rename or delete the file) Is there anything that still has some open filehandle to the mdb ? I noticed when i wait a few seconds ( loop containing Application.Doevents() )
5
14125
by: Rob R. Ainscough | last post by:
I'm using a BackgroundWorker to perform a file download from an ftp site. Per good code design practices where I separate my UI code from my core logic code (in this case my Download file method in my FileIO class) I've established Public Event in my core logic classes along with RaiseEvents (that will updated a progress bar on the UI side). This all works great when I'm NOT using Threading (BackgroundWorker), however, as soon as I...
1
3226
by: Bob | last post by:
Hi, I am having trouble seeing how this bolts together. The UI starts a process which involves a long running database update. All Database activity is handled by a class called DT. DT has a progress event. So I added a bw to the form. The Dowork Calls a method which instantiates a DT and calls its Dataprocessing method.
14
6382
by: =?Utf-8?B?SXNobWFlbA==?= | last post by:
Hi, I have a form with a progress bar on it and wanted to use the BackgroundWorker to be able to update the progress. I looked at examples, run some of them, but in debug, when the code gets to the do work method, it stops for a long while and then executes the first line of the method and the doesn't do anything else. What am i doing wrong?
9
18019
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a backgroundworker and then use the Show method and hide method as necessary? Anyone know of
1
2079
by: Mel | last post by:
I am performing the same recordset multiple times, just passing different parameters each time. Is there a way to do this more efficiently without having to close and re-open the connection and reader? I thought there might be a cleaner way, this code seems to take "forever" to run. '-------BEGINNING OF CODE EXAMPLE------- Dim SBInvNum As String Dim strConInv As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source =" &...
0
1074
Plater
by: Plater | last post by:
So it occured to me that I told people to use this to solve some thread-safeing issues, but that I had not been using it myself (I had been using a delegate with invokerequired which seemed to lock up program on closing) Anyway, I've been using the example on msdn for using backgroundworker to do async stuff. The problem is IT STILL claims to be making unsafe thread calls. The setup for the backgroundworker: private BackgroundWorker...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.