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?
Thanksyes you missed something. see brett's sticky at the top of the page.|||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!!.
Thursday, March 8, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment