Hack 83. Override the Timeout Interval
In a busy network environment, a little patience is sometimes necessary.
When using Access to connect to an external database, performance depends on a number of factors. One of these is the networkspecifically in regard to bandwidth and traffic. Bandwidth might be constant, but add in the dynamic of network traffic, and you often don't know what to expect.
To be on the safe side of having your processing complete, even if it takes a while longer, you can turn off the ADO CommandTimeout property. The default is for a timeout to occur after 30 seconds. This means that if the server has not communicated back to your application in 30 seconds, your application assumes a response isn't coming. You might then see a timeout message such as the one shown in Figure 8-19.
Figure 8-19. A timeout expired error message
Setting the timeout interval to 0 turns off this property. Your application will then wait indefinitely for a response. Assuming an ADO connection object named conn is being used, this is how you apply the setting:
conn.CommandTimeout = 0
The drawback to this approach is that you really might wait forever. By the very nature of turning off the timeout, you have no specific period of reasonable time to expect for the processing to complete. If someone pulled the plug on the server, you might not know it. If it makes sense, though, you can experiment with different settings. Note that the value used is in seconds, so a value of 300 sets the timeout interval to five minutes. Knowing the wait is no more than five minutes for success or failure might make more sense than waiting indefinitely.