QSql bindValue issue
-
Hi,
My name is Kaan and I'm student. I writing a program and i was see an error. While i look generated SQL, i see blank SQL values. Please help me. (Sorry for my bad English.)
My code is here:
#include <QCoreApplication> #include <QDebug> #include <QSql> #include <QSqlQuery> #include <QSqlDatabase> #include <QSqlError> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE"); database.setDatabaseName("C:/Veritabani.db"); database.open(); qDebug() << database.lastError(); QSqlQuery query; query.prepare("INSERT INTO Users(username, e_mail, password) VALUES(:username, :e_mail, :password)"); query.bindValue(":username", "Kaan"); query.bindValue(":e_mail", "kaansef@gmail.com"); query.bindValue(":password", "123456"); query.exec(); qDebug() << query.executedQuery(); return a.exec(); }
-
Hi and welcome to devnet,
You should check that your query executed successfully as well as the error message that it produced otherwise.
One of the first thing that comes to mind is: Do you have that table in your database ?
-
Thank you very much but i'm sure my database table is true. How to see my query's prepared state?
-
How did you check that you are currently have that table in your database ? How did you add it to your database ?