C ++中的PreparedStatement和Array

时间:2013-09-04 10:11:16

标签: c++ mysql

这就是我定义数组的方法

  const int MAXMATCH = 10;
  string A[MAXMATCH] = {"g111", "g112", "g113"};

使用下面的代码,我打算在查询中使用该数组

  con->setClientOption("libmysql_debug", "d:t:O,/tmp/mysql.trace");
  string A[MAXMATCH] = {"g111", "g112", "g113"};
  pstmt = con->prepareStatement("SELECT lenght FROM rods WHERE name = ? ");
    for (int i = 0; i < MAXMATCH; i++)
    {
      string lastmatch = A[i];
      pstmt->setString(1, lastmatch);        
      res = pstmt->executeQuery();   
      con->setClientOption("client_trace", &on_off); 
      res->afterLast();   
      while (res->previous())         
      cout << "\t... Lenght ...: " << res->getInt("lenght") << endl;
      delete res;
    }

代码编译,但我没有得到任何结果。从数组传递到setstring一定有什么问题,但我不明白问题是什么。

0 个答案:

没有答案