Use ADo, where you can set the length of time for connection/query timeout(s).