If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > 24000 : Invalid cursor state, prepared statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-01-06, 11:59
insyst_soft insyst_soft is offline
Registered User
 
Join Date: May 2006
Posts: 4
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?

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-02-06, 14:45
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Post your code. Also, what exact version of Pervasive are you using?
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 05-03-06, 12:38
insyst_soft insyst_soft is offline
Registered User
 
Join Date: May 2006
Posts: 4
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.

SQLCloseCursor(StmtHandle);
SQLBindParameter(........);
rc= SQLExecute(StmtHandler);

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On