I am currently using the following way to access the content of a resultset from a prepared statement
std::string SQL = "....";
prep_stmt = con->prepareStatement(SQL);
res = prep_stmt->executeQuery();
if(res->next()) //If object exists
{
res->getString("ColumnName"); //Access the content of a column
}
Is there any way for me to access the rows in a result set in advance before res->next()
give a try to the rowsCount() method
cout << "Number of rows : " << res->rowsCount() << endl;
Edit: Notice rowsCount returns a size_t
Result = mysql_store_result( Connection );
if (Result) {
RowsReturned = mysql_num_rows( Result );
} else {
RowsReturned = 0;
}
See this relevant question (It's where I shamelessly copied the code from (a).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With