![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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)". |
#3
| |||
| |||
|
|
Mathieu Pagé wrote: 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)". I think you're expecting Row::at() to return false (or, rather, an object that can be converted to false) when you walk off the end of the result set. MySQL++ doesn't do that sort of thing, by design. It signals errors with exceptions, just as you saw. That is the fall-back behavior when you turn off exceptions, however. Read the user manual for details. You might also look at examples/simple3.cpp. It operates in a way very similar to what you're doing, without needing special treatment. It does that by using a different type of query than you are using. Hi M. Young |
#4
| |||
| |||
|
|
Mathieu Pagé wrote: I looked at simple.cpp and tried to do the same thing in my code (using "res.fetch_row()") and I got the same error. Yes, I realized after I sent it that the simple*.cpp examples all turn off exceptions. I didn't post about that because I wasn't sure it mattered, and didn't have time to test it. Sorry for the hassle. Hi, |
#5
| |||
| |||
|
|
It turns out I was not using the right mysql++.lib files. I was using a release one to link into a debug executable. |
![]() |
| Thread Tools | |
| Display Modes | |
| |