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. reading multiline value from database, then using the value in query
Forum Updated to NodeBB v4.3 + New Features

reading multiline value from database, then using the value in query

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 450 Views 2 Watching
  • 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.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    i'm reading (possibly) multiline (i.e. containing '\n') values from sqlite database and storing them in QString.
    later, i need to use this value in a query like this:

    SELECT SomeID FROM SomeTable WHERE SomeText LIKE :the_text;
    

    when i bind the value of stored string to :the_text, something goes wrong and it matches 0 results.
    this is only true when the text is multiline. for single line it works fine. any idea what i can do?

    JonBJ 1 Reply Last reply
    0
    • GerhardG Offline
      GerhardG Offline
      Gerhard
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • GerhardG Offline
        GerhardG Offline
        Gerhard
        wrote on last edited by
        #3

        Most RDBM requires a Wildcard in the searchvalue if there is a LIKE in the WHERE clause.
        if the_text containing the values delivered from previous select try :
        SELECT SomeID FROM SomeTable WHERE SomeText = :the_text;

        Sorry for my english:)

        U 1 Reply Last reply
        1
        • GerhardG Gerhard

          Most RDBM requires a Wildcard in the searchvalue if there is a LIKE in the WHERE clause.
          if the_text containing the values delivered from previous select try :
          SELECT SomeID FROM SomeTable WHERE SomeText = :the_text;

          Sorry for my english:)

          U Offline
          U Offline
          user4592357
          wrote on last edited by
          #4

          @Gerhard
          that returns 0 (doesn't match the text in db)

          1 Reply Last reply
          0
          • U user4592357

            i'm reading (possibly) multiline (i.e. containing '\n') values from sqlite database and storing them in QString.
            later, i need to use this value in a query like this:

            SELECT SomeID FROM SomeTable WHERE SomeText LIKE :the_text;
            

            when i bind the value of stored string to :the_text, something goes wrong and it matches 0 results.
            this is only true when the text is multiline. for single line it works fine. any idea what i can do?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @user4592357
            Do you mean the text you are searching for (bound to the_text) contains newlines, or do you just mean the column in the database you are searching in (SomeText) contains newlines while the text you are searching for (the_text) does not contain newlines? Give us an example of what you are binding the_text to?

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

              Hi,

              To add to @JonB, please give an example of text you are storing in your database and an example of search you are currently doing.

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

              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