[Qt-interest] QSqlQuery::exec: database not open error
Xiaolei Shang
xiaolei.shang at cobham.com
Thu Feb 3 17:46:14 CET 2011
On 03/02/2011 14:22, Gigin Jose wrote:
> Hi,
>
> I am developing a QT application for my ARM based embedded device. In
> my application, I am working on two databases, one is the local
> database on the memory of the device and the other is on a remote MS
> SQL server desktop. Here is how I initialize both the databases:
>
> *QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE","local");*
> *QSqlDatabase db1 = QSqlDatabase::addDatabase("QODBC","remote");*
>
> Both the databases are getting open, which I am checking with db.open.
> But once I try to execute query for any database, (eg. create table),
> I am getting the error *"QSqlQuery::exec: database not open"*
> If I work with just once database, I am not getting the error and can
> comfortably execute queries within that database.
>
> Why is this happening ? How can I comfortably work with more than one
> database in an application ?
>
>
> With Regards
> GIGIN
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
Hi:
When you defined your QSqlQuery pointer or object, did you include your
correspoinding database object? For example:
QSqlQuery localQuery(db);
QSqlQuery remoteQuery(db1);
Xiaolei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110203/848af462/attachment.html
More information about the Qt-interest-old
mailing list