List:MySQL++« Previous MessageNext Message »
From:Yassin Date:August 30 2007 2:25pm
Subject:std::vector of mysqlpp::Row
View as plain text  
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?
Thread
std::vector of mysqlpp::RowYassin30 Aug
  • Re: std::vector of mysqlpp::RowWarren Young31 Aug
    • Re: std::vector of mysqlpp::RowYassin31 Aug
      • Re: std::vector of mysqlpp::RowWarren Young4 Sep