問題是這樣的,閑來無事想練習下mysql++的使用例子,結果總是出現莫名其妙的錯誤。。。。
特意對代碼做了簡化,貼上來,前來求救各路大牛
#include <iostream>代碼很簡單,就是連接資料庫aries_role后,然后從role表中查找ID為99的角色
#include <mysql++.h>
using namespace std;
int main()
{
const char* db = "aries_role", *server = "127.0.0.1", *user = "root", *pass = "123456";
mysqlpp::Connection conn(false);
// 連接資料庫
if (conn.connect(db, server, user, pass))
{
// 從role表中查找ID為99的角色
mysqlpp::Query query = conn.query("select * from role where id = 99");
mysqlpp::StoreQueryResult resu = query.store();
int nRows = resu.num_rows();
if (nRows > 0)
{
cout<<nRows<<endl;
cout<<resu.size()<<endl;
}
else
{
std::cout << "Failed to get item list: " << query.error() << endl;
}
}
return 0;
}
但是結果運行到最后的時候總是會報錯!!!!

意思是變數resu導致堆疊溢位了么????
我進行了列印:
cout<<nRows<<endl;的列印為1,這說明確實查詢到了這個角色
cout<<resu.size()<<endl;的列印為20428360,這是什么鬼,有這么多資料???也許就是這個導致上面的堆疊溢位吧
到底是哪里出了問題呢,請教各位資料庫大牛,小生先謝過了
uj5u.com熱心網友回復:
先自己頂頂,來牛人看看吶,這個問題只有我遇到了么
uj5u.com熱心網友回復:
問題已解決,是因為Debug版的程式用了Release版的庫檔案.........轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/90932.html
標籤:MySQL
上一篇:kettle 輸入輸出 ROWID無法轉換為INTEGER
下一篇:頁注腳與總結帶區問題
