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
    Message: [Pervasive][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
    Dec 2001
    Provided Answers: 6
    Post your code. Also, what exact version of Pervasive are you using?
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    May 2006
    Thanks for replying.

    i found the solution ( mistake in coding).
    I feel satisfied for tracing solution and also feel ashamed that I have to test 50-60 times for this.

    I was making fundamental miatake, due to less experience with SQL ( and also prepared statement )

    the solution is :-

    Handle of scrollable cursor need to be closed, beforing, binding new values in prepared statement.

    rc= SQLExecute(StmtHandler);

    Looks logical.
    If you have better solution, I am open for all suggestions.

Posting Permissions

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