Error: no matching function for call to 'QSqlQuery::addBindValue(std::string&)'



  • I have this code

    @
    include <iostream>
    include<QSqlDatabase>
    include<QSqlQuery>
    #include <hyrje.h>
    using namespace std;
    class Votuesi
    {
    private:
    string v_id,emeri,mbiemer,atesia,qarkui,passi;
    public:
    bool lidhDatabase();
    void identifikohu();
    Votuesi(string ,string ,string );
    void publiko(){
    cout<<v_id<<qarkui<<passi;}};
    Votuesi::Votuesi(string a,string b,string c){
    emeri=a;
    qarkui=b;
    passi=c;}
    //Metode e cila ben te mundur lidhjen e programit me database-in
    bool lidhDatabase(){
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("evoting");
    db.setUserName("root");
    db.setPassword("");
    if (!db.open())
    return cout<<"Lidhja me database-in nuk mund te behet "; }
    return cout<<"Lidhja me database-in u krye me sukses";}
    //Metode e cila ben te mundur identifikimin e numrit te identitetit te votuesit
    void Votuesi::identifikohu(){
    QSqlQuery query;
    query.prepare("SELECT * FROM evoting WHERE emer = ? and qyteti = ? and pass = ?");
    query.addBindValue(this->emeri);
    query.addBindValue(this->qarkui);
    query.addBindValue(this->passi);
    query.exec();
    if(query.size()> 0){
    query.next();{
    else{
    cout<<"Te dhenat qe ju vendoset nuk jane te sakta";}}
    int main(){
    Votuesi votues("Amarda","Tirane","amarda");
    votues.lidhDatabase();
    votues.publiko();
    votues.identifikohu();}@

    what should I do to give the query my values of constructor ?



  • "QSqlQuery::addBindValue":http://qt-project.org/doc/qt-5.0/qtsql/qsqlquery.html#addBindValue expects a valid Qt data type such as QString but you are providing STD string instead.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.