Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsI am executing a query against a DB2 database on an AS400 using VB. I create a connection using ADO, execute the query, and bring back the result into a recordset. The problem I am having is with the connectiontimeout parameter of ADO. The default is 30 seconds. Most queries I have take only a couple of seconds to execute. Once in a while I get a query that takes longer, but certainly not longer than 30 seconds. The problem is that before the query is executed, DB2 estimates how long it will take to execute. If it thinks it will take longer than the value specified in the connectiontimeout, it will not even attempt to execute the query. This is a problem as the reality is the query only takes a couple of seconds to execute, but DB2 in some cases comes back with estimates of 20 minutes or longer, and does not execute the query.
What I would really like to have happen is for the query to execute, and if it goes longer than the timeout, have it fail at that point. I do not want to set an unreasably long timeout, or let it execute forever.
So my question is, does anyone know how to turn the estimator off and keep the commandtimeout reasonable.
Here is an example of the code that is used to execute the query:
Dim objRS As ADODB.Recordset
Dim objCmd As ADODB.Command
Set objCmd = New ADODB.Command
With objCmd
Set .ActiveConnection = objCTIconn ' This is the Connection
.CommandText = strQuery ' This is the query being execued
.CommandTimeout = 30 ' Timeout of 30 seconds. This is also default.
.CommandType = adCmdText
Set objRS = .Execute
End With
Set GetCtiDATA = objRS
Exit Function
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: LowfatspreadPosted on 2003-06-18 at 05:43:25ID: 8748624
Comments are available to members only. Sign up or Log in to view these comments.