Data connection taking minutes to close

krausr79

Board Regular
Joined
Feb 12, 2012
Messages
209
I'm trying to update an access database from excel with an SQL statement. I've tried ADODB command execution, ADODB connection.execute, and DAO database.execute. The data update is successful, but any time the connection gets closed, excel/vba become unresponsive for 5-10 minutes. We are using Office 2010

This person seems to have had the same problem, but I've tried waiting after executing for a couple minutes to close the connection and it hasn't helped.

VBA ADODB Connection close taking too long - Excel 2010 - Stack Overflow

Code:
    Dim CN As ADODB.Connection
    Dim CM As ADODB.Command
    Set CN = New ADODB.Connection
    CN.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=S:\Mydbaddress\db.accdb"
    Set CM = New ADODB.Command
    CM.ActiveConnection = CN
    CM.CommandText = sql
    CM.Execute
    Do Until CN.State = 1
        Debug.Print CN.State
        DoEvents
    Loop
    Set CM = Nothing
    CN.Close 'Hangs up here
    Set CN = Nothing

or

Code:
    Dim DB As DAO.Database
    Set DB = Workspaces(0).OpenDatabase("S:\OSK-Share\DEPT\ILS\IPSQCBE1.accdb")
    DB.Execute sql, dbFailOnError
    DB.Close 'Hangs up here
    Set DB = Nothing
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
We never really figured out what was wrong, but we have a workaround. This was a large (over 1 gig) backend on a company shared drive. We split the backend into two backends and had just the stuff relevant to the excel part in it. Then it worked faster again.
 
Upvote 0

Forum statistics

Threads
1,216,113
Messages
6,128,905
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top