Hi, I'm trying to store result rows in a vector, like this:
mysqlpp::Connection con(...);
mysqlpp::Query query = con.query();
query << "SELECT * FROM test_table";
std::vector<mysqlpp::Row> v;
query.storein(v);
for (std::vector<mysqlpp::Row>::iterator i = v.begin(); i != v.end(); ++i)
{
mysqlpp::Row row = *i;
for (mysqlpp::Row::iterator it = row.begin(); it != row.end(); ++it)
std::cout << *it << "\t";
std::cout << std::endl;
}
However, I get an access violation error.
The following codes works correctly:
mysqlpp::Connection con(...);
mysqlpp::Query query = con.query();
query << "SELECT * FROM test_table";
mysqlpp::Result res = query.store();
for (mysqlpp::Result::iterator it = res.begin(); it != res.end(); ++it)
{
mysqlpp::Row my_row = *it;
for (mysqlpp::Row::iterator it2 = my_row.begin(); it2 !=
my_row.end(); ++it2)
std::cout << *it2 << "\t";
std::cout << std::endl;
}
Anyone knows what's the problem?