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!

How to get sqlcode from ODBC call to IBM host

Status
Not open for further replies.

MrStar

Programmer
Sep 30, 2002
53
0
0
DK
I'm sending a sql to IBM host from MS Access through ODBC.

If I made an error in this SQL, I only got at message telling that ODBC call has failed. (error number 3146)

Is it possible to retrieve the sqlcode from Host ?

I have tried to use API call GetLastError, but it allways gives me a zero.

A coding example would be nice ?
 





Hi,

"Is it possible to retrieve the sqlcode from Host ?"

It's YOUR SQL.

Please post your SQL.

What DB in IBM? Is it DB2?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Yes it is DB2

It is not any particular sql.
I mean in genereal - how to retrieve sqlcode.

If I have a date in wrong format I would like to get -181
 




You do not retrieve SQL code. YOU supply the code and retrieve the resultset of data specified by your SQL. I do not at all understand your question.

By what method do you send your query?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
This is part opf the code I use for sending my query to Host DB2.

Set QueCV = dbs.CreateQueryDef("")
With QueCV
.Connect = "ODBC;DATABASE=" & f_DB2System & ";UID=" & _
f_UserId & ";PWD=" & _
f_Psword & ";DSN=" & f_DB2System
.SQL = strSql
.ODBCTimeout = 0
.ReturnsRecords = True

Set HostRs = .OpenRecordset()

If I have an error in my sql, then the code will fail in 'Set HostRs = .OpenRecordset()' with err.number = 3176.

StrSql containes the sql like this:
Select CARD_PRODUCT_ID FROM KSP0.CARD_PRODUCT
WHERE CARD_PRODUCT_ID in ('LSMC')
AND CURRENT DATE
BETWEEN START_DATE AND VALUE (EXPIRATION_DATE, DATE('31.13.9999'))
group by CARD_PRODUCT_ID ;

As you can see, I have made an error in the date, and Host will erespond -181, but I can't get this sqlcode into Access.

 
You may play with the Errors collection.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have tried the errors collection, but it dosn't give me anything.
 




This is the first time you have mentioned Access. You might be better off posting in Forum705.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks, I will try this forum instead.
 



Sorry, so he did.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top