Re: ADO Connection Timeout
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Fri, 29 Dec 2006 15:46:50 -0500
Robert McCarter wrote:
Hello,
I am trying to configure ADO to give me a trappable error when the
connection to my Access database becomes unavailable. I created the
following variables in a module and made them public:
Is this a VB application? Or in an Access VBA module?
Public MSCn as New ADODB.Connection
Public MSCd as New ADODB.Command
Public MSRs as New ADODB.Recordset
In my startup form, I set all of these variables and connect to the
database etc. What I am trying to accomplish is this: When I have a
good connection the remote machine that holds the Access database
(normal operation) everything runs normally. However, if the link to
the remote database is severed (cable unplugged, database damaged, or
some other problem) I want to use a database local to the machine
running the program.
I have tried to set up a test program that connects to the remote
database and then physically unplugging the cable. I cannot get
around the default 30 second timeout. I would like a timeout of 5
seconds to try the main server and if I get an error, swap over to
the local database. When I am running my program, and I unplug the
cable it still takes 30 seconds to get an error. I have tried
ConnectionTimeout on the connection and CommandTimeout on the Command
and had no luck.
Furthermore, when I do get an error, it is one of those messagebox
(Debug, End) errors. I would like to make a global error trap
instead of having to code "on error..." stuff in each sub since I use
the aforementioned variables all over my program. I tried to use
WithEvents when dimensioning my connection and could not get the
InfoMessage Event to fire.
Again ... VB or VBA?
I would appreciate any ideas any of you could give me. This program
is to be run in a production environment on an assembly line that
indexes at 20 seconds per cycle. So, I do not have much time to wait
for timeouts etc. if I have problems.
There is no avoiding this delay if you use a Connection to test the database
existence.
However, if you use a FileSystem object, you should have better success. Set
a Reference to the Windows Scripting Host and try this:
Function DBExists(byval FilePath as String) As Boolean
Dim fso As New FileSystemObject
DBExists = fso.FileExists(FilePath)
End Function
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- Re: ADO Connection Timeout
- From: Robert McCarter
- Re: ADO Connection Timeout
- Prev by Date: Re: 2147217865 Error Message Attempting to Populate a RecordSet from a DB2 Database
- Next by Date: Re: ADO Connection Timeout
- Previous by thread: 2147217865 Error Message Attempting to Populate a RecordSet from a DB2 Database
- Next by thread: Re: ADO Connection Timeout
- Index(es):
Relevant Pages
|