Qt-interest Archive, April 2007
Fwd: sqlite problem "library routine called out of sequence"
Message 1 in thread
---------- Forwarded message ----------
From: Yogesh M <yogeshm02@xxxxxxxxx>
Date: 01-Apr-2007 11:46
Subject: Re: sqlite problem "library routine called out of sequence"
To: SABROG <sabrog@xxxxxxxxx>
On 31/03/07, SABROG <sabrog@xxxxxxxxx> wrote:
> Ok, i found problem, strange what query not global for child blocks O.o
>
> This work fine:
> if (db.open())
> {
> QSqlQuery query;
> if (!query.exec("create table images (locationid int, file
> varchar(20))"))
> {
> qDebug(qPrintable(query.lastError().text()));
> }
>
>
> SABROG ÐÐÑÐÑ:
> > Can you help me. I don't know why i get error: "library routine called
> > out of sequence" from sqlite driver. This my code:
> >
> > #include <QtGui>
> > #include <QtSql>
> > #include "TForm.h"
> >
> > TForm::TForm()
> > {
> > setupUi(this);
> > db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"));
> > db.setDatabaseName("test.db3");
> > QSqlQuery query;
> > if (db.open())
> > {
> > if (!query.exec("create table images (locationid int, file
> > varchar(20))"))
> > {
> > qDebug(qPrintable(query.lastError().text()));
> > }
> > }
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
Perhaps the problem was that QSqlQuery object was created before db.open().
--
[ signature omitted ]
Message 2 in thread
Hi,
> db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"));
> db.setDatabaseName("test.db3");
> QSqlQuery query;
> if (db.open())
> [...]
Here is the documentation for the QSqlQuery constructor:
http://doc.trolltech.com/4.2/qsqlquery.html#QSqlQuery-2
Constructs a QSqlQuery object using the SQL query and the
database db. If db is not specified, the application's
default database is used. If query is not an empty string,
it will be executed.
So first make sure there's a default application database:
http://doc.trolltech.com/4.2/qsqldatabase.html#database
Returns the database connection called connectionName.
The database connection must have been previously added
with addDatabase(). If open is true (the default) and
the database connection is not already open it is opened
now. If no connectionName is specified the default
connection is used. If connectionName does not exist
in the list of databases, an invalid connection is returned.
--
[ signature omitted ]