PDA

View Full Version : Why sqlite db address not working at all?



mr.farahmand
3rd February 2012, 10:34
Hi
I'm using sqlite with Qt library


#include <QtSql/QSqlDatabase>
#include <QSqlQuery>

this is my code for connection :


QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
mydb.setDatabaseName(QCoreApplication::application DirPath() + "/data/27115");
mydb.open();
QSqlQuery query("SELECT * FROM setting");
if (mydb.open())
{
query.exec();
int fieldNo = query.record().indexOf("theme");
while (query.next()) {
ui->cmb_themes->addItem(query.value(fieldNo).toString());
}
}
mydb.close();


Now in my system,its work right without any problem,but i copied debug folder in other computer and run, my application cant find db file!!

in other system i installed qt sdk and open myapp.pro on it,and run.. next .. db file could run and worked.why?
in my laptop with Windows7 64 bits , output address is : '.....'-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug

and in other computer with windows 7 32 bits , output address is : '.....'-build-desktop

thanks before answer

wysota
3rd February 2012, 11:29
Did you deploy the sqlite driver to the other machine?

mr.farahmand
3rd February 2012, 11:36
No.i'm using it direct(with db file address)
how can i?
if deploy sqlite,it can works?

wysota
3rd February 2012, 11:38
http://www.qtcentre.org/threads/45444-QSqlDatabase-cannot-open-database?p=208354#post208354

mr.farahmand
3rd February 2012, 12:02
oh yes.very good answer
so thanks