Error While Using SQLite
-
Hi,
I am new to QT and finding problems while connecting it to SQLite. I hope you will help me in solving this..
I am using following settings to connect.. I have created library.db using NAVICAT.
@
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("C:\sqlite\library.db");
if (!db.open()) {
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());
return false;
}
return true;
@These errors are shown while compiling..
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to
_imp___ZN12QSqlDatabase17defaultConnectionE' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to
imp___ZN12QSqlDatabase11addDatabaseERK7QStringS2'
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to_imp___ZN12QSqlDatabaseD1Ev' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:17: undefined reference to
_imp___ZN12QSqlDatabase15setDatabaseNameERK7QString'
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:18: undefined reference to_imp___ZN12QSqlDatabase4openEv' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to
_imp___ZNK12QSqlDatabase9lastErrorEv'
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to_imp___ZNK9QSqlError4textEv' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to
_imp___ZN9QSqlErrorD1Ev'
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to_imp___ZN9QSqlErrorD1Ev' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:23: undefined reference to
_imp___ZN12QSqlDatabaseD1Ev'
debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:23: undefined reference to `_imp___ZN12QSqlDatabaseD1Ev'[EDIT: code formatting, please wrap in @-tags, Volker]
-
Thanks Voker. It's working fine now:-)
I have one more question..
If I encrypt this database, how can I use it in QT? means what will the way to decrypt it and performing operations on the data.
-
[quote author="khalidmushtaq65" date="1299184561"]
If I encrypt this database, how can I use it in QT? means what will the way to decrypt it and performing operations on the data.
[/quote]Not without additional libraries. The built-in SQLite version cannot handle encrypted databases.