[Interest] QtSql database insertion issues...

BRM bm_witness at yahoo.com
Wed Apr 22 19:43:15 CEST 2015


I had thought about that which is why I dumped the boundValues() as part of the error after exec().
I'll try dumping prior to exec().
However, it didn't seem to matter whether I used position or named bindings, the results were the same.
Ben
 


     On Wednesday, April 22, 2015 3:55 AM, Tony Rietwyk <tony at rightsoft.com.au> wrote:
   

 #yiv1822332023 #yiv1822332023 -- _filtered #yiv1822332023 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv1822332023 {font-family:PMingLiU;panose-1:2 2 5 0 0 0 0 0 0 0;} _filtered #yiv1822332023 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv1822332023 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv1822332023 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv1822332023 {panose-1:2 2 5 0 0 0 0 0 0 0;}#yiv1822332023 #yiv1822332023 p.yiv1822332023MsoNormal, #yiv1822332023 li.yiv1822332023MsoNormal, #yiv1822332023 div.yiv1822332023MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1822332023 a:link, #yiv1822332023 span.yiv1822332023MsoHyperlink {color:blue;text-decoration:underline;}#yiv1822332023 a:visited, #yiv1822332023 span.yiv1822332023MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv1822332023 p.yiv1822332023MsoAcetate, #yiv1822332023 li.yiv1822332023MsoAcetate, #yiv1822332023 div.yiv1822332023MsoAcetate {margin:0cm;margin-bottom:.0001pt;font-size:8.0pt;}#yiv1822332023 p.yiv1822332023msonormal, #yiv1822332023 li.yiv1822332023msonormal, #yiv1822332023 div.yiv1822332023msonormal {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1822332023 p.yiv1822332023msochpdefault, #yiv1822332023 li.yiv1822332023msochpdefault, #yiv1822332023 div.yiv1822332023msochpdefault {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv1822332023 span.yiv1822332023msohyperlink {}#yiv1822332023 span.yiv1822332023msohyperlinkfollowed {}#yiv1822332023 span.yiv1822332023emailstyle17 {}#yiv1822332023 p.yiv1822332023msonormal1, #yiv1822332023 li.yiv1822332023msonormal1, #yiv1822332023 div.yiv1822332023msonormal1 {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv1822332023 span.yiv1822332023msohyperlink1 {color:blue;text-decoration:underline;}#yiv1822332023 span.yiv1822332023msohyperlinkfollowed1 {color:purple;text-decoration:underline;}#yiv1822332023 span.yiv1822332023emailstyle171 {color:#1F497D;}#yiv1822332023 p.yiv1822332023msochpdefault1, #yiv1822332023 li.yiv1822332023msochpdefault1, #yiv1822332023 div.yiv1822332023msochpdefault1 {margin-right:0cm;margin-left:0cm;font-size:10.0pt;}#yiv1822332023 span.yiv1822332023EmailStyle27 {color:#1F497D;}#yiv1822332023 span.yiv1822332023BalloonTextChar {}#yiv1822332023 .yiv1822332023MsoChpDefault {font-size:10.0pt;} _filtered #yiv1822332023 {margin:72.0pt 72.0pt 72.0pt 72.0pt;}#yiv1822332023 div.yiv1822332023WordSection1 {}#yiv1822332023 Not all drivers support named bindings.  If it doesn't, then the driver replaces them with positional ? during execute.   Try dumping insertion.boundValues() before calling exec.    Otherwise, I think you'll need to step through in a debug build and set a breakpoint in Qt where the error is raised.   Tony    From: BRM [mailto:bm_witness at yahoo.com] 
Sent: Wednesday, 22 April 2015 2:12 PM
To: Tony Rietwyk; 'Qt Project'
Subject: Re: [Interest] QtSql database insertion issues...  The "prepare(...)" does seem to work.  One thing that really confuses me is that even though I use the named bindings, it always lists the bindings as '?' in the error messages.  Ben    On Tuesday, April 21, 2015 11:20 PM, Tony Rietwyk <tony at rightsoft.com.au> wrote:  Hi Ben,  Does the prepare work?  I assume the database must be open, or you would get a different message.  Hope that helps,  Tony  From: interest-bounces+tony=rightsoft.com.au at qt-project.org [mailto:interest-bounces+tony=rightsoft.com.au at qt-project.org] On Behalf Of BRM
Sent: Wednesday, 22 April 2015 12:42 PM
To: Qt Project
Subject: [Interest] QtSql database insertion issues... I've been out of the Qt loop for a little bit; but I'm working to bring myself back up to speed.I'm presently working on a small project that is basically a GUI equivalent of md5sum/sha1sum where I'm attempting to store the data in a SQLite Database during run-time. I've already done a command-line version using python, and I'm pulling the SQL statements from there. However, I am having trouble with the QSqlQuery prepared statements. The entire code chunk is here:
https://github.com/BenjamenMeyer/qtmd5gui/blob/branch_qt4_base/src/hash_db.cpp I'm building the project on Kubuntu 14.10, using the Qt4.8 libraries provided by the distro. To summarize the code, I'm doing the following:     QSqlQuery insertion(myDb);    insertion.prepare("INSERT INTO master_directory (hash, path) VALUES(:hash, :path)");    insertion.bindValue(":hash", "some hash");    insertion.bindValue(":path", "/some/path");    if (!insertion.exec()) qDebug() << "insertion failed. Log errors and value bindings"; I've added debug output that shows the values being bound; however, it continues to complain about a parameter mismatch. You can see the output here:https://gist.github.com/BenjamenMeyer/dffe01b702dc8f507c17 I've tried binding both by name (preferred) and by order. (I have a C Preprocessor Define to control it); but neither are working. This is my first time really playing with a database via Qt.What am I doing wrong? TIA, Ben   _______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest  
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150422/c2b452ac/attachment.html>


More information about the Interest mailing list