[Qt-interest] QSqlDriver::sqlStatement returns an empty string...

Eric Clark eclark at ara.com
Tue May 11 18:28:29 CEST 2010


I checked the lastError()  and there are no errors returned by the driver after the call to sqlStatement. Here is what the code looks like:

QSqlRecord record = db.Record("TableName");
QString query = db.driver()->sqlStatement(QSqlDriver::InsertStatement, "TableName", record, true);

The "db" variable is a valid database connection that is open and has been tested and queried. I have tried passing in QSqlDriver::UpdateStatement and false as the last parameter, but in all cases I get an empty string back. Obviously, the "TableName" is not actually "TableName", it is the name of a table that DOES exist in the database. The record that is returned has 3 fields in it because I also printed that out to the screen to see if the record was null or had an error in it, but it is not. This is all I am doing right now, and it never seems to give me anything other than an empty string. I am not sure if this code will help because you also need a database, but it is exactly what I have.

Thanks,
Eric

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andre Somers
Sent: Tuesday, May 11, 2010 11:00 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QSqlDriver::sqlStatement returns an empty string...

On 11-5-2010 17:41, Eric Clark wrote:
Hello All,

I am having an issue with the SqLite driver. I am trying to prepare a query using the sqlStatement() function. Every time I call it, whether I pass in InsertStatement or UpdateStatement I get an empty string returned. I have double-checked to make sure the table exists and that the record I pass in has valid fields and everything seems to be fine except the fact that it always returns an empty string. Has anyone experienced this problem before? Is this a limitation with the SqLite driver or something?

Thank You in advance!
Eric

Could you show the relevant code?
sqlStatement() is a bit of an unpolished beast. I had some problems with it myself before, and it is hardly documented.

André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100511/fcd35863/attachment.html 


More information about the Qt-interest-old mailing list