how to connect to sqlite database
Unsolved
General and Desktop
-
i want to connect to sqlite database
this is my code:QSqlDatabase Database; Database.addDatabase("QSQLITE"); Database.setDatabaseName("C:/Users/ARASH/Desktop/arash.db"); if (!Database.open()) { qDebug() << Database.lastError().text(); }
but return me "Driver not loaded Driver not loaded"
I copy qsqlite.dll in sqldrivers folder inside my app folder but don't work
-
i want to connect to sqlite database
this is my code:QSqlDatabase Database; Database.addDatabase("QSQLITE"); Database.setDatabaseName("C:/Users/ARASH/Desktop/arash.db"); if (!Database.open()) { qDebug() << Database.lastError().text(); }
but return me "Driver not loaded Driver not loaded"
I copy qsqlite.dll in sqldrivers folder inside my app folder but don't work
-
about how to connect to sqlite database, what's the best form to do the connection?, once tiem at start and only get connexion or connect and close on each query.
and is possible do update with bindvalue?thank you, sorry for my english!
@Yugui
Often best design is open once at start.
and close at end.- and is possible do update with bindvalue?
yes. it is.
QSqlQuery query; query.prepare("INSERT INTO person (id, forename, surname) " "VALUES (:id, :forename, :surname)"); query.bindValue(":id", 1001); query.bindValue(":forename", "Bart"); query.bindValue(":surname", "Simpson"); query.exec();