Results 1 to 2 of 2

Thread: update query don't work

  1. #1
    Join Date
    Dec 2015
    Posts
    5
    Thanks
    3
    Qt products
    Qt5 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default update query don't work

    I have a problem withe the query :

    Qt Code:
    1. MyActionQuery->prepare("UPDATE Ahmed.creditor SET crebalance = '"+AmeelNewbal+"' where CRECODE = '"+ZoalCode+"'");[CODE]
    To copy to clipboard, switch view to plain text mode 
    [/CODE]

    it gave me the error :

    D:\KhalidQtAppllns\Applications\IsamSales\LOVdialo g.cpp:121: error: invalid operands of types 'const char [41]' and 'double' to binary 'operator+'
    Qt Code:
    1. MyActionQuery->prepare("UPDATE Ahmed.creditor SET crebalance = '"+AmeelNewbal+"' where CRECODE = '"+ZoalCode+"'");
    To copy to clipboard, switch view to plain text mode 
    ^
    crebalance is a table field of type number, AmeelNewbal is a double variable, ZoalCode is a variable of type char and crecode is a primary key of type char

    I'm connecting with Oracle 11g

    Can any one help me about it ...!!!!

    Thank You in advance ...

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: update query don't work

    1. This have nothing with SQL - this is a problem with string operator + (as compiler said).
    2. Please read about QSqlQuery::prepare and use placeholders.

  3. The following user says thank you to Lesiok for this useful post:

    Khalifa (28th January 2016)

Similar Threads

  1. QSqlQuery update query not working using SQLite
    By Cyrebo in forum Qt Programming
    Replies: 2
    Last Post: 29th March 2013, 01:33
  2. SQL query does not work every time
    By Mobility in forum Newbie
    Replies: 8
    Last Post: 13th January 2013, 07:48
  3. SQLITE - UPDATE query problem
    By Tomasz in forum Newbie
    Replies: 12
    Last Post: 5th September 2010, 21:27
  4. SQL slow query - table update
    By lasher in forum Newbie
    Replies: 4
    Last Post: 22nd October 2009, 00:12
  5. Update query
    By apffal in forum Qt Programming
    Replies: 4
    Last Post: 7th August 2009, 17:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.