Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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?



  • This post is deleted!


  • 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:)



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



  • @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?


  • Lifetime Qt Champion

    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.


Log in to reply