Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SQLQuery Like problem
QtWS25 Last Chance

SQLQuery Like problem

Scheduled Pinned Locked Moved Solved General and Desktop
qsqlquerybinding
3 Posts 2 Posters 631 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gaab
    wrote on last edited by gaab
    #1

    The following query give the expected result from DBBrowser for SQLite

    select ident, name, laty, lonx, state, country from airport where scenery_local_path like '%FOLDER NAME%' order by country, state ;
    

    With QT SQLQuery and C++, the following code

    quAddOns->prepare("select ident, name, laty, lonx, state, country from airport  where scenery_local_path like :AddOn order by :Sort ;")
    
     quAddOns->bindValue(":AddOn", "%FOLDER NAME%");
     quAddOns->bindValue(":Sort", "country, state" );
    
     quAddOns-exec();
    

    gives the correct number of result but don't sort !
    If I modify (without the :Sort bind value)

    quAddOns->prepare("select ident, name, laty, lonx, state, country from airport  where scenery_local_path like :AddOn order by country, state")
    

    gives the expected sorted results !

    If I try to insert single quote (as with DB Browser) or double quote, either inside the prepare string or in the value to bind, the result exec() is empty (but no error).

    I don't understand what I am doing wrong :(
    Suggestions are VERY welcome...

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      To the best of my knowledge, bind parameters doesn't apply to elements of the query like sort.

      That one you'll have to build the string with it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        To the best of my knowledge, bind parameters doesn't apply to elements of the query like sort.

        That one you'll have to build the string with it.

        G Offline
        G Offline
        gaab
        wrote on last edited by
        #3

        @SGaist

        My bad ! I did not think to check the docs on that point !

        A big thanks
        Gérard

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved