PDA

View Full Version : Problem inserting data into sqlite



thefatladysingsopera
12th August 2011, 07:40
I have the following code in my save function.


void smith::on_saveButton_clicked()
{

QSqlQuery query;

query.prepare(
"INSERT INTO application (firstname, lastname, country, city)) "
"VALUES (:firstname, :lastname, :country, :city)"
);

query.bindValue(":firstname", "Alexis");
query.bindValue(":lastname", "Nicholov");
query.bindValue(":country", "Russia");
query.bindValue(":city","Moscow");
query.exec();
}

The database connection is alright but it wont insert.Why?.

Lykurg
12th August 2011, 07:47
What error do you get? See QSqlQuery::lastError().


EDIT: You have a ) to much after city