|
Exception of type std::length_error: msg#00016db.mysql.c++
Hi everyone, I hope this has not been asked before, I searched the online archives of the list and could not find any references to my problem. I'm trying to run a simple test program based on the simple1 example. I can get connected to the DB, I create a query and execute it. q.size() return 4 wich is the number of row I expected so the query is fine. Then I try to enumerate the result of the query like this : <code> mysqlpp::Row row; mysqlpp::Row::size_type i; for (i = 0; row = res.at(i); ++i) cout <<row.at(0) <<endl; </code> however I get an length_error exception on "row = res.at(i)". Since I'm new to MySQL++, maybe i'm doing something stupid and someone can point me to it. Thanks in advance. Mathieu Pagé Complete code : #include <mysql++.h> #include <iostream> #include <exception> using namespace std; int main(int argc, char* argv[]) { try { // On se connecte à la DB mysqlpp::Connection con(true); con.connect("chess", "localhost", "root", "SomePassword"); if (!con) { cout <<"erreur" <<endl <<con.error() <<endl; return 1; } // On créer une requête mysqlpp::Query q = con.query(); q <<"SELECT NomJoueur FROM tblJoueurs"; // On exécute la requête mysqlpp::Result res = q.store(); cout <<"Il y as : " <<res.size() <<" lignes." <<endl; // On affiche la liste des joueurs if (res && res.size() > 0) { mysqlpp::Row row; mysqlpp::Row::size_type i; for (i = 0; row = res.at(i); ++i) { cout <<row.at(0) <<endl; } } else { cout <<"Erreur dans la requête : " <<q.error() <<endl; return 1; } } catch (mysqlpp::ConnectionFailed e) { cout <<e.what() <<endl; } return 0; } -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-plusplus@xxxxxxxxxxx |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Patches?!: 00016, Warren Young |
|---|---|
| Next by Date: | Re: Could not find working MySQL client library!: 00016, Remi Collet |
| Previous by Thread: | Re: [bug #7474] SSQLS compare operators patchi: 00016, Warren Young |
| Next by Thread: | Re: Exception of type std::length_error: 00016, Warren Young |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |