0

这就是我定义数组的方式

  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 肯定有问题,但我不明白问题是什么。

4

0 回答 0