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. insert into...values (...accents...)
Qt 6.11 is out! See what's new in the release blog

insert into...values (...accents...)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 749 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.
  • CadNetoC Offline
    CadNetoC Offline
    CadNeto
    wrote on last edited by
    #1

    Please, how to solve problems like:

    QString a = "macdonald's";
    "insert into clients (name) values ('" + a + "')";

    this accents <'> is the problem.

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

      Hi,

      IIRC you have to double the single quote if you want to insert one in your database field.

      Hope it helps

      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
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        And you might be able to do it with

         a.replace("'","''");
        
        1 Reply Last reply
        2
        • CadNetoC Offline
          CadNetoC Offline
          CadNeto
          wrote on last edited by
          #4

          So many thanks. It works !

          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