请问mysql++有关问题,commands out of sync

请教mysql++问题,commands out of sync

我用mysql++ api来操作mysql数据库,

部分大致程序如下:

  Connection con;

  con.set_option(new MultiStatementsOption(true));

  if (!con.connect(mysqlpp::examples::db_name, cmdline.server(),

  cmdline.user(), cmdline.pass())) {

  return 1; }

  string str = “DROP TABLE IF EXISTS test_table;

  CREATE TABLE test_table(id INT); 

  INSERT INTO test_table VALUES(10);

  UPDATE test_table SET id=20 WHERE id=10;”;

  Query query = con.query();

  StoreQueryResult res = query.store();

这个程序段会杯多次执行,第一次执行时正常,但第二次执行时报query异常,“commands out of sync,you can’t run this command now”。

请高手指教。



由于你是多条sql语句一次执行,因此必须把StoreQueryResult取尽才能执行下一次sql

看看能不能用query.store() != null不断取出再关闭。

请问mysql++有关问题,commands out of sync

相关文章:

你感兴趣的文章:

标签云: