HOWTO: Trap for ADO Connection Errors Using WithEvents (190991)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
This article was previously published under Q190991 SUMMARY
Microsoft ActiveX Data Objects (ADO) allows developers to define ADO
object variables using the WithEvents keyword. With this functionality developers can trap for errors that occur while trying to establish an ADO connection to a data source.
To properly trap for errors such as an incorrect user ID, incorrect
password, or a connection timeout error, you must declare your ADO
connection variable using the WithEvents keyword, and you must attempt to establish your ADO connection asynchronously. Under these conditions, ADO connection errors can be processed in the ConnectionComplete event of the ADO connection object.
REFERENCES
In the Microsoft Developer Network Library for Visual Studio 6.0; search on: "ADO Event Model and Asynchronous Operations"; "ConnectComplete and Disconnect(ConnectionEvent) Methods (ADO)"
Modification Type: | Minor | Last Reviewed: | 3/2/2005 |
---|
Keywords: | kbDatabase kbhowto KB190991 |
---|
|