Results 1 to 15 of 15

Thread: QSqlQueryModel setQuery problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    58
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    3

    Default QSqlQueryModel setQuery problem

    Hi guys,

    I'm stuck with a problem, I was so proud that the search function worked in my table view

    This is the code
    Qt Code:
    1. orderModel->setQuery("SELECT c.*, o.* FROM clients AS c, orders AS o WHERE o.cid = c.cid and o.currentStatus = 1 AND articleDescription LIKE '%blaat%'");
    To copy to clipboard, switch view to plain text mode 

    But it has to be dynamical sow I came up with this piece of code

    Qt Code:
    1. QSqlQuery query;
    2. query.prepare("SELECT c.*, o.* FROM clients AS c, orders AS o WHERE o.cid = c.cid and o.currentStatus = 1 AND :column LIKE '%:searchString%'");
    3. query.bindValue(QString(":column"), QVariant(column));
    4. query.bindValue(QString(":searchString"), QVariant(searchString));
    5.  
    6.  
    7. //orderModel
    8. orderModel->setQuery(query);
    To copy to clipboard, switch view to plain text mode 

    Before I wrote this code I did use a QString and the append function to generate the code. And that didn't work even.

    I tested the query and it works well.

    Does somebody know how to solve this problem?
    Last edited by cyberboy; 10th March 2008 at 17:00. Reason: spelling error

Similar Threads

  1. QSqlQueryModel write subclass
    By skuda in forum Qt Programming
    Replies: 6
    Last Post: 29th October 2007, 17:18
  2. Replies: 16
    Last Post: 7th March 2006, 16: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
  •  
Qt is a trademark of The Qt Company.