没有可用于" mysql_fetch_row()的源位于0x7ffff78cc6a5"

时间:2013-11-12 09:56:28

标签: c++ mysql eclipse

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

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行,我从eclipse cdt应用程序中获得了mysql_fetch_row() at 0x7ffff78cc6a5错误的无源。

问题是查询在我的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];

0 个答案:

没有答案