Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006

    Unanswered: 24000 Invalid cursor state. Prepared Statement

    I have written a routine to search a unique record using prepared statement. Its my first sql coding with c++.

    I am not using / importing any dlls.

    I connect+allocs handels , then use SQLPrepare(StmtHandle, SQLStmt,SQL_NTS); to generate a guery.

    I have written bind parameters and sqlexecute +sqlFetch in a loop and loop gets executed till ESC key is pressed.

    First time when I bind paramaters using SQLBindParameter it works perfect.

    When loop gets executed secondtime onwards, it gives an error.
    SQLState: 24000 [ODBC Client Interface]Invalid cursor state.

    If I open connection, handles, and prepared starement in same loop, THEN it gives correct record without 24000 error.

    I want the advantage of prepared staement. So I do not want to close and open connection and prepare statement every time.

    Have I missed any step?
    Where & when I should code the cursor type? Any specific libraries I need to link?


  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    yes you missed something. see brett's sticky at the top of the page.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    May 2006
    I traced the solution.

    I thought that the mistake is in declaring scrollable cursors.

    So I explained precisouly the problem in 7-8 lines.
    Reading 50-60 lines with altogether different coding standards is difficult.

    Its not coding problem but associated with scrollable cursor options.
    So I did not include the code.

    MSDN examples does not show such required step as the scope of example code gets over before such situation is reached!!.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts