Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO error trapping

Status
Not open for further replies.

dantar

MIS
Jan 17, 2003
14
0
0
US
Does anyone out there know how to trap an error in an ADO operation? For example, when using the update method after the addnew method, if the record I'm adding would create a duplicate primary key, an ADO error displays, but I haven't been able to determine how to capture the error code. Any help would be appreciated.
 
As you have not given us enough information about your COBOL vendor/version I am giving you the information for VB.

The ADODB object as a connection object.
This is defined as
Dim conn As New ADODB.Connection

In turn the Connection object has a errors collection.
The errors collection in turn contains the error object.

conn.Errors.Count
will return the number of error objects on the collection

The error collection contain several properties, including the following ones.
conn.Errors(1).Description
conn.Errors(1).NativeError
conn.Errors(1).Number
conn.Errors(1).source


The above should help you to build your COBOL code.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks.

I'm sorry I neglected to say that I am using Fujitsu NetCobol version 7, specifically PowerCobol for this application.
 
Look at the ADO examples supplied with FJ. There are four of them.

The error can be trapped using the following construct

MOVE "Description" OF "Item"(a) OF "Errors" OF "Connection" OF CmADODataSource1 to w-error-description-of-ado-error

As I said before if you looked at the VB example you would notice that I mentioned that the connection object had a errors collection
e.g. "Errors" OF "Connection"

Then this has a error object

"Item"(a) OF "Errors" OF "Connection"

And so on.

To trap the display of the Fujitsu error message window there is a parameter you place on your .cbr file to prevent this. Search the manuals for it.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
In AcuCobol we have what are called declaratives, which are basically paragraphs of code that get triggered when an exception occurs (be it on a file IO, an object such as ADO, etc).

Does Fujitsu have something like that?

.DaviD.
 
I'm new to Fujitsu, so I'm not sure, but it's worth checking. Thanks for the suggestion.
 
np. let me know!

Also, question for you - since you're now coding in a .NET environment, does that mean that you're using ADO 2.8 (the .NET version), or do you still have the choice of using 2.7 and earlier?

The reason I ask is because MS changed a whole bunch of stuff betweent the two versions, and especially locking is differnet. We're still on 2.7 because of that (in ACU Cobol), and I just wanted to see how Fujitsu is doing.

Thx,
 
Davidk13

Neetcobol V7 and Power COBOL are not a ".NET" tool.



Yes the Declaratives section can also be used to trap errors, but it won't prevent the display of the window I mentioned.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top