Answer the question
In order to leave comments, you need to log in
C++ QT why query to sql Lite DB doesn't work?
Hello everyone!)
Actually, for some reason, the entry into the database of the values entered in the edit does not work.
The request from the database works, that is, to check if there are any fields there, it comes out, but there are some problems with this.
Here is the function code:
QMessageBox mess;
QString Name,Email,Password;
Name=ui->lineEdit->text();
Email=ui->lineEdit_2->text();
Password=ui->lineEdit_3->text();
QSqlDatabase regDB;
regDB=QSqlDatabase::addDatabase("QSQLITE");
regDB.setDatabaseName("D:\\database.db3");
if(!regDB.open())
{
ui->label->setText("Data Base isn't open");
}
QSqlQuery query;
query.prepare("INSERT INTO People (Name, Password, E-mail) VALUES(?, ?, ?)");
query.addBindValue(Name);
query.addBindValue(Password);
query.addBindValue(Email);
if(query.exec())
{
qDebug()<<"All ok";
}
else
qDebug()<<"loseee";
mess.setText("Register is secseful");
mess.exec();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question