0
我試圖從表中選擇的ID其中,IP地址= [字符串]C++的MySQL連接器選擇從字符串
我會從另一個函數來獲取IP地址
std::string GetIP(){
return IP;
}
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1.:3306", "root", "password");
con->setSchema("Test");
stmt = con->createStatement();
string GETI = "84.54.584.6"; // will be GetIP()
res = stmt->executeQuery("SELECT ID FROM IPs Where IP_Address = '"+ GETI +"'");
while (res->next()) {
cout << "id = " << res->getInt(1);
}
delete res;
delete stmt;
delete con;
我沒有得到任何錯誤Visual Studio中的錯誤列表
但是當我嘗試
當我運行它不顯示值和應用程序崩潰應用
res = stmt->executeQuery("SELECT ID FROM IPs Where IP_Address = '84.54.584.6'");
我得到它做工精細
任何解決方案~~~ !!! –
您是否嘗試調試應用程序?哪條線路導致崩潰? – triclosan
我覺得有選擇的線:) –