ADODB Recordset timing out but not giving an error

Zabman

Board Regular
Joined
Apr 7, 2010
Messages
77
Hi,

I have a macro that connects to a DB2 database and returns a recordset that I complete subsequent actions with. I have found that longer queries are causing excel to stall - giving me the 'this program is not responding' and forcing me to restart excel. I have played around with the command timeout setting in the connection and extending this out has given me the results I require.... howerer.... I am not happy with this as it still has the problem if query times increase again.

I would expect an error to be thrown up which I can deal with instead of the program just crashing but this isnt happening. I have confirmed there are no 'On Error goto' things so I am stumped as to how to resolve this.

I am creating the recordset like this:
DBRS.Open SQL, CN, adOpenStatic, adLockOptimistic, adCmdText

where SQL is my query, and CN is my connection.

Can anyone help?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I am just completing an app that is querying a DB with 30,000 records of 24 columns and a read of all like this:

Code:
    With CreateObject("ADODB.Recordset")
        .Open "SELECT * FROM PaidJobs", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Sett.Cells(38, 2) & "KKDB.accdb;"
        DBPJ.Range("A2").CopyFromRecordset .DataSource
        .Close
    End With

completed in around 2.6 seconds and a search like this:

Code:
    Dim rst As Object: Set rst = CreateObject("ADODB.Recordset")
    rst.Open "SELECT * FROM " & Tbl & " WHERE " & Fld & " LIKE " & Fnd & ";", _
        "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Sett.Cells(38, 2) & "KKDB.accdb;"
    Srch.Range("A2").CopyFromRecordset rst.DataSource
    rst.Close: Set rst = Nothing

completed in 1,1 seconds.
 
Upvote 0

Forum statistics

Threads
1,215,762
Messages
6,126,740
Members
449,335
Latest member
Tanne

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