MySQL Forums
Forum List  »  Connector/C++

Problems with getString method
Posted by: Michael Pilz
Date: December 09, 2011 08:16AM

Hi I want to get some strings from my SQL database. So I did a search for the wanted entries and after a quick check of how many he found it seems that he successfully did the search.

but now I have the problem with getting the wanted values from the searched entries (its a String).
I would have thought that the proper method for this would be getString(x) where x is either the desire Columnindexnumber or directly the title of the column.

However he crashes everytime I want to use this function. He throws the Exception "sql::InvalidArgumentException" which I cant really understand why because the indexnumber or indexname should be right.

Or did I understand something wrong?

Anyway here's the code:

sql::ResultSet* result = fw->database->Query("SELECT `email` FROM `users` WHERE `id`='%i'", user_id)
int rows = result->rowsCount(); // he should find 3 entries and after calling rowsCount(), rows contains indeed the value 3
int n = result->getMetaData()->getColumnCount(); // contains the value 1 afterwards (because I only select one column, namely "email" ?)

// I tested every single of these parameters just to be sure but I get everytime the exception
result->getString(0);
result->getString(1);
result->getString("email");
result->getString("`email`");

Options: ReplyQuote


Subject
Views
Written By
Posted
Problems with getString method
2301
December 09, 2011 08:16AM


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.