"Invalid cursor state"
What is it? and why do I receive that error on some systems (not all)?
How do I fix that?
Take care,
Skorpio
"Invalid cursor state"
What is it? and why do I receive that error on some systems (not all)?
How do I fix that?
Take care,
Skorpio
1. ODBC "invalid cursor state"
My VC++ program was fine with this:
retcode = SQLAllocStmt(hdbc, &hstmt);
retcode = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
sizeof(selectstatement));
retcode = SQLExecute(hstmt);
retcode = SQLBindCol(hstmt, 1, SQL_C_LONG, &account_no, 0, &cbtest);
retcode = SQLFetch(hstmt);
SQLFreeStmt(hstmt, SQL_DROP);
then I added another select:
retcode = SQLAllocStmt(hdbc, &hstmt);
*********
retcode = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
sizeof(selectstatement));
retcode = SQLExecute(hstmt);
retcode = SQLBindCol(hstmt, 1, SQL_C_LONG, &account_no, 0, &cbtest);
retcode = SQLFetch(hstmt);
*******
retcode = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
sizeof(selectstatement));
retcode = SQLExecute(hstmt);
retcode = SQLBindCol(hstmt, 1, SQL_C_LONG, &account_no, 0, &cbtest);
retcode = SQLFetch(hstmt);
********
SQLFreeStmt(hstmt, SQL_DROP);
but it failed with SQLPrepare "invalid cursor state"
so i fixed it by allocating and deallocating before each select. Shouldn't
there be a SQLZeroStmt() or something that'll clear the statement without
forcing me to alloc/dealloc each time? This seems inefficient.
this works:
retcode = SQLAllocStmt(hdbc, &hstmt);
retcode = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
sizeof(selectstatement));
retcode = SQLExecute(hstmt);
retcode = SQLBindCol(hstmt, 1, SQL_C_LONG, &account_no, 0, &cbtest);
retcode = SQLFetch(hstmt);
SQLFreeStmt(hstmt, SQL_DROP);
*******
retcode = SQLAllocStmt(hdbc, &hstmt);
retcode = SQLPrepare(hstmt, (SQLCHAR*) selectstatement,
sizeof(selectstatement));
retcode = SQLExecute(hstmt);
retcode = SQLBindCol(hstmt, 1, SQL_C_LONG, &account_no, 0, &cbtest);
retcode = SQLFetch(hstmt);
SQLFreeStmt(hstmt, SQL_DROP);
thanks
2. BTR 2 DDF ?
3. "Invalid cursor state" / Error 0x80004005
4. DateTime field in Database Error
5. "Invalid cursor state" error
6. Trying to use SQL Mail from the DMZ
7. SQL 7.0 error "Invalid Cursor State"
8. news server
12. "Invalid Argument" ODBC error
13. "Cursor state not valid.", AS400 JDBC, IBM JTOpen 3.0