• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

invalid cursor state SQLPrepare (after select)

Hi experts,

I perform 2 statements:  Select and then insert.

The select works fine and in my SQLPrepare(hStatement) for the insert, I get the error.

If I don't do my select, my SQLPrepare and execute on my insert works fine.

Any ideas???

Thanks - and 500 points to the person who helps!  =)

Cheers,
Mike
0
mikexpert
Asked:
mikexpert
  • 3
  • 2
1 Solution
 
snoyes_jwCommented:
This doesn't look like a problem with MySQL. You might get a better answer in the appropiate language TA, such as MFC.
0
 
mikexpertAuthor Commented:
yep - thanks...
0
 
mikexpertAuthor Commented:
ok snoyes_jw - here's the real issue:

I execute two queries:  one is a select and the other following one is an insert.

The SELECT works fine but then I get the error in in my SQLPrepare for the INSERT.  If I omit the SELECT, I don't get an error in the INSERT...

Any ideas???

Thanks so much... and you're already gonna get the points for this question... (promise).. If you're able to answer this new one, I've posted it in two places - you'll get a total of 1500 points (this question plus two of the new one I'm asking you)...  (I don't really know if you care about points - but I hope you do!)   =)

Thanks a bundle!
Mike

0
 
snoyes_jwCommented:
SQLPrepare is not a MySQL thing; it is specific to some programming language(s), and not any that I know.  You haven't even mentioned which language you are using, and you might have confused MySQL with the Microsoft SQL or SQL Server areas.

A few moments on Google reveals the following, any of which no doubt mean more to you than they do to me:

- You cannot reuse the Statement Handle when the cursor is in use in this memory table.  Try to free the statement handle using some sort of "FreeStatement" function.

- SELECT statements return a result set; INSERTS do not.  Perhaps using the SELECT first sets the handler to expect a result set; when none is returned with the INSERT, the error is raised.

- If you're really using SQL Server, take a look here: http://www.windowsitpro.com/Article/ArticleID/43010/43010.html

Incidentally, in an attempt to curb "point inflation", the maximum legal points for any one question is 500.  That includes asking the same question in multiple areas.

I recommend that you post in the Community Support area and ask a moderator to delete and refund this question, and then post in the topic area related to whatever programming language you are using.
0
 
mikexpertAuthor Commented:
Thanks for the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now