This is a discussion on Mixing SQL_LEN_DATA_AT_EXEC, 0, and SQL_NULL_DATA with SQLPrepare within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Can anybody tell me if I am doing something wrong here, or, can Microsoft verify if this is a ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Can anybody tell me if I am doing something wrong here, or, can Microsoft verify if this is a bug in SQL Server? If I prepare a simple insert, for example, "INSERT INTO MYTABLE(MYCOL) VALUES (?)", and then, bind an SQL_LONGVARCHAR column, for example: SQLBindParameter(hstmt, 1, 1, 1, -1, 2147483647, 0, data, 0, &indicator); then, if I set the ODBC environment attribute SQL_ATTR_ODBC_VERSION to SQL_OV_ODBC2, I can choose between SQL_LEN_DATA_AT_EXEC(length) (and use SQLPutData), 0, and SQL_NULL_DATA for the indicator, each time I call SQLExecute (after SQLPrepare). If I set SQL_OV_ODBC3, mixing these indicators causes "Invalid Cursor State", when using SQLPrepare + SQLExecute (vs. SQLExecDirect). 1. Prepare the statement and bind. 2. Set the indicator to SQL_LEN_DATA_AT_EXEC(some length > 0) and use SQLExecute, SQLParamData, SQLPutData, SQLParamData to send the bytes. 3. Now try to set the indicator to 0 (or, SQL_NULL_DATA). If that succeeds, try sending another row with length > 0. With SQL Server 2000, 8.00.2039, I get "Invalid Cursor State". If I set SQL_LEN_DATA_AT_EXEC(0) I can then SQLPutData 0 bytes, but if I want to send SQL_NULL_DATA, I have to either: (1) set SQL_LEN_DATA_AT_EXEC(0), and SQLPutData SQL_NULL_DATA, which IMHO does not follow the ODBC spec, or (2) use SQLExecDirect, or (3) use SQL_OV_ODBCV2. Regards, Jim Flood |
| Thread Tools | |
| Display Modes | |
|
|