[Qt-interest] Problem with QSqlQuery ?
Israel Brewster
israel at frontierflying.com
Wed Sep 16 00:00:00 CEST 2009
On Sep 15, 2009, at 1:44 PM, Scott Aron Bloom wrote:
> Well for one.. why are you putting it on the heap?
>
> That said, I almost NEVER use the second form..
> Typical usage for me..
>
> QSqlQuery query
> query.prepare( xxxx )
> if ( !query.exec() )
> {
> //Error handler
> qDebug() << query.lastError();
> }
>
>
> With the constructor you don't know it failed.
Sure you do - just check if query.lastError.isValid. I almost NEVER
use the first form. Typical usage for me:
QSqlQuery query(xxxx);
if( query.lastError.isValid() )
{
//Error handler
qDebug() << query.lastError();
}
-----------------------------------------------
Israel Brewster
Computer Support Technician II
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------
>
> Scott
>
>
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Mhayk Whandson
> Sent: Tuesday, September 15, 2009 2:35 PM
> To: Qt Interest (qt-interest at trolltech.com)
> Subject: [Qt-interest] Problem with QSqlQuery ?
>
> Hi all, I would like to know what is the difference between this 2
> options below:
>
> #define RESTART_SEQUENCE_DSM_TEMP_ITEMS_PRESELL_ID "alter sequence
> dsm_temp_items_presell_id_seq restart with 1"
>
> First:
> QSqlQuery *restart = new QSqlQuery;
> restart->prepare(RESTART_SEQUENCE_DSM_TEMP_ITEMS_PRESELL_ID);
> restart->exec();
> delete restart;
>
> Second:
> QSqlQuery *restart = new
> QSqlQuery(RESTART_SEQUENCE_DSM_TEMP_ITEMS_PRESELL_ID);
> delete restart;
>
> The query just work with the second option :\ why ? I need to pass to
> the QSqlQuery constructor ? Is it true ?
>
> --
> Mhayk Whandson
> Linux User #413723
> E-mail: eu at mhayk.com.br
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Israel Brewster.vcf
Type: text/directory
Size: 417 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090915/399cf4fb/attachment.bin
-------------- next part --------------
More information about the Qt-interest-old
mailing list