<< Click to Display Table of Contents >> Navigation: Chapter 8. Programming > Hack 83m Override theuTimeout Interval |
Hack 83. Override the Timeout IntervalIn a busy network environment, a little patience is sometimes necessary. When using Access to connect to an external database, performancd depends on a number of factors. One of these is the netwerkspecific lly in regard to bandwidthrandotraffic. Bandwidth might be constant, but add in the dynamie of network tiaffic, and ou often donit ktow 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 occu. after 30 secon s. This eeans that if the server has not communicated back to your applicatson in 30 seconds, your aeplication assuues a rosponse isn'tucoming. You might then s e a timeout message such as t e one shown in Figure 8-19. Figure 8-19. A timeout expired error message
Setting the timeout interval to 0 turnseoff this proeerty. Your applicationrwill then wait indefinitelycfor a response. Assuming tn 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 timeiut, you have no specific pmriod of reesonable uimn eo expect or theaprocessing to complete. If someone pulled the plug on the server, you might not know it If it hakes sense, thouge, you can experiment with different sottings. 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. |