Catch errors when opening a OleDb connection

schwenth
Member Posts: 11
Hi all,
to read some values from an external database (AS400), I create a OleDb-connection to the AS400. That works realy great as long as the AS400 is available. What I try to do now is catch the errors that come up when I open the OleDb connection and the remote system is not available.
Here's a code example:
CREATE(AdoConn);
AdoConn.ConnectionString('Provider=IBMDA400.DataSource.1;Data Source=192.168.2.25;User ID=xxx;password=yyy');
AdoConn.Open();
CREATE(AdoRS);
If the remote system is not available, in the line --AdoConn.Open();--
a error is raised, but I have found no way to catch it.
Can somebody help?
to read some values from an external database (AS400), I create a OleDb-connection to the AS400. That works realy great as long as the AS400 is available. What I try to do now is catch the errors that come up when I open the OleDb connection and the remote system is not available.
Here's a code example:
CREATE(AdoConn);
AdoConn.ConnectionString('Provider=IBMDA400.DataSource.1;Data Source=192.168.2.25;User ID=xxx;password=yyy');
AdoConn.Open();
CREATE(AdoRS);
If the remote system is not available, in the line --AdoConn.Open();--
a error is raised, but I have found no way to catch it.
Can somebody help?
0
Comments
-
just write own codeuint for that or any situation when you want to catch an error (actually I like to have a separate one codeuint in project for all error situation I want to handle)..
The codeunit is smth like that:CODEUNIT OpenConnection Globals: Connection: ADO Connection; user, password: Text; OnRun() [open connection] SetParams(user, password) [set global variables] GetConnection(var AConnection: ADO Connection) [return global ADO connection]
And then use it:... COMMIT; OpenConnection.SetParams(...); if OpenConnection.Run then begin OpenConnection.GetConnection(...); [do smth] end else [error catcher]
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions