我使用以下代码,我收到此错误
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 在'??]附近?j?X?0'在第1行
我的代码如下,这在调试版本中非常有效
#include <iostream>
#include <vector>
//#define CPPCONN_PUBLIC_FUNC
/* MySQL Connector/C++ specific headers */
#include <driver.h>
#include <connection.h>
#include <statement.h>
#include <prepared_statement.h>
#include <resultset.h>
#include <metadata.h>
#include <resultset_metadata.h>
#include <exception.h>
int main()
{
sql::Driver *driver;
sql::Statement *stmt;
sql::ResultSet *res;
sql::Connection *con;
sql::PreparedStatement *prep_stmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("server", "user", "pass");
/* Connect to the MySQL database */
con->setSchema("MySchema");
std::vector<std::string> SymbolList;
std::string SQL = "SELECT `MyList`.`Symbol` FROM `MySchema`.`MasterList`;";
try
{
stmt = con->createStatement();
res = stmt->executeQuery(SQL);
while(res->next()) //If object exists
{
std::string symbol = res->getString("Symbol");
SymbolList.push_back(symbol);
std::cout << symbol;
}
}
catch(std::exception &ex)
{
std::string d = ex.what();
}
std::cin.get();
return 0;
}//end method
我仍然对错误感到困惑我得到的代码似乎在调试模式下正常工作但在发布模式下它会出现这个错误。关于我应该尝试什么以及我可能做错什么的任何建议。我正在使用VS2010.I还可以上传我创建的小项目