0
我有64位,下載了32,但崩潰(這是因爲沒有與LIB文件的錯誤少,所以我不得不使用32,但) 所做的一切都是在這裏:http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-apps-windows-visual-studio.html#connector-cpp-application-build-dynamic的MySQL在連接功能
但該計劃在「connect'function崩潰:
http://imageshack.us/photo/my-images/827/25478716.jpg/
任何想法,該怎麼辦? 這裏是我想編譯的源代碼。
#include <stdlib.h>
#include <iostream>
#include <Windows.h>
/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
//__declspec(dllexport)
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
using namespace std;
int main(void)
{
cout << endl;
cout << "Running 'SELECT 'Hello World!' » AS _message'..." << endl;
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "pass");//
/* Connect to the MySQL test database */
con->setSchema("test");
stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("_message") << endl;
cout << "\t... MySQL says it again: ";
/* Access column fata by numeric offset, 1 is the first column */
cout << res->getString(1) << endl;
}
delete res;
delete stmt;
delete con;
} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << ")" << endl;
}
cout << endl;
return EXIT_SUCCESS;
}
dopn't您指定的連接字符串? – 4pie0 2013-03-20 00:40:18
奇怪,但在VS 2008的工作..我可以使它在這VS12工作? – user2080060 2013-03-20 00:43:55