I got a annoying problem. There's a code in qt that does not work correctly, there's no syntax and runtime errors, only sqlite3 does not like my query.
This function removes friend or friends that user has selected on his profile window clicking on the pushbutton.
bool Profilewindow::removeFriends() {
QList<QListWidgetItem *> selectedFriends = ui -> userfriendsList -> selectedItems();
QSqlQuery query;
QStringList stringlist;
if ( MainWindow::getInstance() -> isConnectedToDB() ) {
query.prepare("DELETE FROM user_friends WHERE user_id = :user_id AND f_fname = :f_fname AND f_lname = :f_lname");
for ( int i = 0; i < selectedFriends.count(); ++i ) {
stringlist = selectedFriends.at(i) -> text().split(" ");
qDebug() << this -> user_id;
query.bindValue(":user_id", this->user_id);
qDebug() << stringlist.at(0);
query.bindValue(":f_fname", stringlist.at(0));
qDebug() << stringlist.at(1);
query.bindValue(":f_lname", stringlist.at(1));
if ( !query.exec() ) {
qDebug() << query.lastError().text();
}
}
MainWindow::getInstance() -> closeDBConnection();
if ( this -> updateFriendsList() ) return true;
return false;
}
return false;
}
all the parameters thats binding are correctly recieved and they are not null or empty string or any other wroung data.
when query is executing qDebug outputs this: "Parameter count mismatch"
can't understand what does this strange error mean ?