だから、私はこの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];