[Qt-interest] QSqlQuery and QSqlTableModel show empty

Jon Flowers Jon.Flowers at pgs.com
Fri May 15 12:44:36 CEST 2009


Well solved the QSqlTableModel issue, bad database username/password
combo. But still can not successfully get a QSqlQuery to execute

 

QSqlQuery myQuery("select * from projects");

myQuery.exec();    <- returns false every time even when the tablemodel
gets filled with data.

 

Any ideas?

 

Thanks

Jon

 

 

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Jon Flowers
Sent: Friday, May 15, 2009 11:18 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QSqlQuery and QSqlTableModel show empty

 

Need some help with the Sql Modules.

I have read some of the books out there and looked at the examples. I
have a postgres database up and running with a table and one row in it.
I can create a connection to this database from main.cpp, but I would
like to use the QSqlTableModel on the mainwindow.cpp class. I have
queried the connection and it says it is active, but when I follow
example to show the table on the gui I get the columns in the header,
but no data. I have tried to get a QSqlQuery to just test things and it
also returns no data. 

...

projModel.setTable("tablename");

projModel.select();

ui.tbvProjects->setModel(&projModel);

ui.tbcProjects->show();

No data comes back but the headers are correct. So that leads me to
believe I do have a connection but the query is not returning any data.
And to answer the obvious, I have verified the table contains data by
pgAdmin from a different machine and also via psql on the database
server (local dev machine).

Any ideas, pointers and general comments welcome....

Thanks

Jon

This email and any files contained therein is confidential and may
contain privileged information. If you are not the named addressee(s) or
you have otherwise received this in error, you should not distribute or
copy this e-mail or use any of its content for any purpose. Please
notify the sender immediately by e-mail if you have received this e-mail
in error and delete it from your system 


This email and any files contained therein is confidential and may contain privileged information.  If you are not the named addressee(s) or you have otherwise received this in error, you should not distribute or copy this e-mail or use any of its content for any purpose. Please notify the sender immediately by e-mail if you have received this e-mail in error and delete it from your system
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090515/1436cd6f/attachment.html 


More information about the Qt-interest-old mailing list