0

所以,我正在构建这个 c++ 应用程序。我正在使用 ubuntu 12.04.3 LTS 和最新的 Eclipse。我已通过链接成功连接数据库 这是代码。

mysql_query(connection," INSERT INTO IdItems(Id, Items ) VALUES (4,19;)");

printf("%ld IdItems Row(s) Updated!\n",
       (long) mysql_affected_rows(connection));

mysql_query(connection, "SELECT Id, Items FROM IdItems WHERE Id=4;");

printf("%ld IdItems Row(s) Updated!\n",
       (long) mysql_affected_rows(connection));

//SELECT newly inserted record.
mysql_query(connection,"SELECT Id FROM IdItems");

err2 = mysql_error(connection);
if (strlen(err2) != 0) {
    //**DEBUG RUNS THROUGH HERE AND THEN SKIPS THE NEXT ELSE BLOCK, so error here**
    printf("%s", err2);
 } else {
    //Resource struct with rows of returned data.
    resource = mysql_use_result(connection);

    string tempvar="";
    // Fetch result
    result = mysql_fetch_row(resource);
    cout<<result[0];
    tempvar = result[0];

在最后 3 行,我mysql_fetch_row() at 0x7ffff78cc6a5从 eclipse cdt 应用程序中得到一个 No source available for error。

问题是查询在我的 sql 数据库上完美地返回了结果。

最奇怪的是,这个类似的查询适用于 eclipse(在 IDTable 上):

mysql_query(connection, "SELECT LAST_INSERT_ID();");

printf("%ld IdTable Row(s) Updated!\n",
       (long) mysql_affected_rows(connection));

//Resource struct with rows of returned data.
err2 = mysql_error(connection);
if (strlen(err2) != 0) {
    printf("%s", err2);
 } else {
    //**DEBUG FINDS NO ERROR AND ENTERS the else block here.
    resource = mysql_use_result(connection);

    string tempvar="";
    // Fetch result
    result = mysql_fetch_row(resource);
    cout<<result[0];
    tempvar = result[0];
4

0 回答 0