On Wed, Jul 20, 2005 at 04:10:46PM -0700, Benjamin Liu wrote:
> Hi folks,
>
> I'm a humble non-programmer who just wants to read a float table value into
> a float variable.
> ----------------------------------------------------------------------------
> -------------
> Query query = con.query();
> query << "select kwh from basic120 order by time desc limit"; // Last value
> this column.
> mysqlpp::ResUse res = query.use();
> ???
> float kwh = ???
> ----------------------------------------------------------------------------
> -------------
> I've tried using the method Fields but can't get it to compile.
Check out the usequery.cpp example, or some of the other files in the
examples/ subdirectory.
Here's a snippet:
// Execute the query, but don't save results in memory
mysqlpp::ResUse res = query.use();
if (!res) {
std::cerr << "Result set is empty!" << std::endl;
return 1;
}
// Iterate through result set, printing each row.
mysqlpp::Row r;
while (r = res.fetch_row()) {
print_stock_row(r);
}
i.e. you need to use a Row object, and fetch each row, then access the
data from that row.
More docs are here: http://tangentsoft.net/mysql++/doc/
- Chris