I created a function to add new records to an sqlite table everything works fine but when trying to insert strings two extra quotes are added
code:
int dBase::ajouter(QString table,QVector<QVariant> valeurs)
{
connect();
QSqlQuery query(db);
QString sql="INSERT INTO "+table+" VALUES (NULL";
for(int i=0;i<valeurs.length();i++)
sql+=", :val"+QString::number(i);
sql+=")";
query.prepare(sql);
for(int i=0;i<valeurs.length();i++)
query.bindValue(":val"+QString::number(i), valeurs.at(i));
int ret=-1;
if(query.exec())
ret=query.lastInsertId().toInt();
else
qDebug()<<query.lastError();
disconnect();
return ret;
}
values as shown when executing select:
1|'Nom'|'Pays'|'Ville'|'Adresse'|1234|'12345678'|'13245678'|'12345678'|'email@email.com'
I discovered this problem when trying to use while Nom="x" it always return no records.