SQLite Out of Memory error
Hi there! This is my first attempt to use QT and a portable db like SQLite.
I've copied some code from a website to include it in my project, but every time I run it it displays the following message:
"Error initializing database: Driver not loaded Driver not loaded"
Here's my simple code:
Code:
QString dbName
= dir.
filePath("gestion_stock.sqlite");
db.setDatabaseName(dbName);
if (!db.open()) {
return db.lastError();
}
if (!q.
exec(QLatin1String("create table if not exists producto(cod_fabrica varchar(20) primary key, " "cod_proveedor varchar(20), cod_local varchar(20), stock integer, "
"stock_minimo integer, precio_compra decimal(5), precio_venta decimal(5), "
"proveedor varchar(20), gondola varchar(5), estante integer)"))) {
return q.lastError();
}
}
Don't mind the spanish names for the table and fields :P
Any help will be appreciated!
Re: SQLite Out of Memory error
In order to use a Sqlite database your program must have access to the QSqlite plugin, which is not available to your program as the error message indicates. Running inside a normal IDE, where Qt is installed, this should be available. If this program is deployed then you must deploy the relevant plugins (sqldrivers folder) along with the Qt libraries.
BTW: Why do you think
Quote:
"Error initializing database: Driver not loaded Driver not loaded"
has anything to do with your thread title?
Quote:
SQLite Out of Memory error
Re: SQLite Out of Memory error
I forgot to change that, at first it said "Out of memory: sqlite something" then it changed to driver not loaded.
I have no idea how to do that, I'm running QtCreator.
If I build the "Books Demonstration" example, which uses SQLite, it works just fine.