我按照教程写了一个例子程序int _tmain(int argc, _TCHAR* argv[])
{
mysqlpp::Connection conn(false); if (conn.connect("MyTestdb1", "localhost", "root", "hechi14")) {
mysqlpp::Query query = conn.query("select phone from mytable");
if (mysqlpp::StoreQueryResult res = query.store()) {
cout << "We have:" << endl;
mysqlpp::StoreQueryResult::const_iterator it; for (it = res.begin(); it != res.end(); ++it) {
mysqlpp::Row row = *it;
cout << '\t' << row[0] << endl;
}
}
else {
cerr << "Failed to get item list: " << query.error() << endl;
return 1;
} return 0;
}
else {
cerr << "DB connection failed: " << conn.error() << endl;
return 1;
}
return 0;
}
编译通过,为啥调试的时候在迭代器这一块总是出错呢?貌似没取到,但是我在mysql的command line client执行查询语句都可以的啊?