MySQL Forums
Forum List  »  Connector/C++

[Resolved Wrong results in example 2.
Posted by: Phuc Sinh Nguyen
Date: May 08, 2012 02:19PM

I think i used a wrong version of "libmysql.dll". So sry. :D

=============================================================================


Sorry for my English.

I got the same problem with this topic:
http://forums.mysql.com/read.php?167,298946,298946

First, the placeholder syntax seem not work:

Code:
==========================================================================
pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
for (int i = 1; i <= 10; i++) {
pstmt->setInt(1, i);
pstmt->executeUpdate();
}
==========================================================================

All of id values are 0. I think they should be 1 to 10.

And the second is result of:

Code:
==========================================================================
/* Select in ascending order */
pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
res = pstmt->executeQuery();

/* Fetch in reverse = descending order! */
res->afterLast();
while (res->previous())
cout << "\t... MySQL counts: " << res->getInt("id") << endl;
==========================================================================

I got 10 of -1163005939 values instead 10 to 1.

I don't know why the topic above had no reply and was locked. I'm new of SQL and my English is bad, but please help me.

Thank you.



Edited 6 time(s). Last edit at 05/09/2012 02:32AM by Phuc Sinh Nguyen.

Options: ReplyQuote


Subject
Views
Written By
Posted
[Resolved Wrong results in example 2.
2346
May 08, 2012 02:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.