2016-04-24 126 views
0

SSQLS定义MySQLHelper.h的MySQL ++无效的参数错误

#ifndef SRC_INCLUDE_UTIL_MYSQLHELPER_H_ 
#define SRC_INCLUDE_UTIL_MYSQLHELPER_H_ 

#if!defined(EXPAND_MY_SSQLS_STATICS) 
#define MYSQLPP_SSQLS_NO_STATICS 
#endif 
#include <ssqls.h> 
sql_create_7(FaceTable, 1, 7, mysqlpp::sql_int, id, mysqlpp::sql_int, label, 
      mysqlpp::sql_int, gender, mysqlpp::sql_double, genderconfidence, 
      mysqlpp::sql_int, age, mysqlpp::sql_double, ageconfidence, 
      mysqlpp::sql_datetime, date) 

using namespace std; 
mysqlpp::Connection connect(); 

然后是MySQLHelper.cpp

#define EXPAND_MY_SSQLS_STATICS 
#include "include/Util/MySQLHelper.h" 

mysqlpp::Connection connect() { 
    const char *SERVER = "127.0.0.1"; 
    const char * USER = "root"; 
    const char * PASSWORD = "123456"; 
    const char *DB ="FaceDB"; 
    mysqlpp::Connection conn(false); 
    if (conn.connect(DB, SERVER, USER, PASSWORD)) { 
     return conn; 
    } 
} 

我想在FaceDAO.h

#ifndef SRC_INCLUDE_DAO_FACEDAO_H_ 
#define SRC_INCLUDE_DAO_FACEDAO_H_ 

#include "include/Core/Face.h" 
#include <vector> 
#include <time.h> 
#include "include/DAO/FaceEntity.h" 
using namespace std; 
class FaceDAO { 
private: 
    mysqlpp::Connection conn; 
public: 
    FaceDAO(); 
    void insert(Face face, time_t time); 
}; 

#endif /* SRC_INCLUDE_DAO_FACEDAO_H_ */ 

使用SSQLS则FaceDAO.cpp

#include "include/Util/MySQLHelper.h" 
#include "include/DAO/FaceDAO.h" 
FaceDAO::FaceDAO() { 
    this->conn = connect(); 
} 
void FaceDAO::insert(Face face, time_t datetime) { 
    mysqlpp::sql_int id(0); 
    mysqlpp::sql_int label(face.getLabel()); 
    mysqlpp::sql_int gender(face.getGender() == "male" ? 1 : 0); 
    mysqlpp::sql_double genderconfidence(face.getGenderConfidence()); 
    mysqlpp::sql_int age(face.getAge()); 
    mysqlpp::sql_double ageconfidence(face.getAgeConfidence()); 
    mysqlpp::sql_datetime date(datetime); 
    FaceTable entity(id, label, gender, genderconfidence, age, ageconfidence, 
      date); 
    mysqlpp::Query query = conn.query(); 
    try { 
     query.insert(entity); 
     query.execute(); 
    } catch (const mysqlpp::Exception &er) { 
     cerr << "Error: " << er.what() << endl; 
     exit(1); 
    } 
} 

但是编译器告诉我query.insert(entity);是错误
误差低于

Invalid arguments ' Candidates are: mysqlpp::Query & insert(const #0 &) mysqlpp::Query & insert(#0, #0) ' 

回答

0

我解决了这个问题,这似乎月食错误。
尝试右键单击您的项目并从 菜单中选择索引 - >重建。