MySQL Forums
Forum List  »  Connector/C++

[mysql++] Vector of mysqlpp::Row
Posted by: Yassin Ezbakhe
Date: August 26, 2007 01:42PM

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 know what's the problem?

Options: ReplyQuote


Subject
Views
Written By
Posted
[mysql++] Vector of mysqlpp::Row
6519
August 26, 2007 01:42PM


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.