Hi,
I am trying to call SQLSetConnectAttr api but I am getting following
error:
SQLSTATE: HY024
Native: -99999
Message: [IBM][CLI Driver] CLI0191E Invalid attribute value.
SQLSTATE=HY024
I have created connection successfully but whiling setting connection
autocommit mode to false I am getting above error.
SQLUINTEGER autocommit;
autocommit = SQL_AUTOCOMMIT_OFF;
rc = SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, (void
*)&autocommit, 0);
Could some pls help ?
Regards
Ajay
Knut Stolze - 30 Dec 2005 09:29 GMT
> Hi,
> I am trying to call SQLSetConnectAttr api but I am getting following
[quoted text clipped - 11 lines]
> rc = SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, (void
> *)&autocommit, 0);
You are calling the function with the wrong parameters, and the explicit
casts prevent your compiler from raising an error/warning. Try this:
rc = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0);
p.s: As a general rule: if you need casts in your code, there is a high
chance that you have a problem in the code itself. (Of course, there are
exceptions to that rule.)

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany
Mark Yudkin - 30 Dec 2005 10:53 GMT
The third parameter is the value, not a pointer to the value. Your use of an
explicit cast to force the wrong value prevents the compiler from telling
you that your code is wrong, so you get told off at runtime.
> Hi,
> I am trying to call SQLSetConnectAttr api but I am getting following
[quoted text clipped - 16 lines]
> Regards
> Ajay