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. Qsqlquery
Qt 6.11 is out! See what's new in the release blog

Qsqlquery

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.6k Views 1 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.
  • Y Offline
    Y Offline
    yakine
    wrote on last edited by
    #1

    hello
    how can i send a text which contain ' to database
    i use a qsqlquery but there is a error if the text contain '
    please help me
    thanks

    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

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

      Hi,

      Haven't tested it, but I would try to escape the character using e.g. it's ascii code

      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
      0
      • Y Offline
        Y Offline
        yakine
        wrote on last edited by
        #3

        hello
        thank you SGaist
        so i must search in the string for the ' and change it with her code ascii?

        IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

        1 Reply Last reply
        0
        • IamSumitI Offline
          IamSumitI Offline
          IamSumit
          wrote on last edited by
          #4

          you can use as following :
          use \' escape sequence
          see -->'\'vermas\''
          QString strQuery("insert into emp values(2,'1989-02-02','amit','\'vermas\'','M','2014-01-01')");

          after executing above using .exec();
          in DB it will send as 'verma' in respective column.
          hope it helps

          Be Cute

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yakine
            wrote on last edited by
            #5

            thank you all
            so to solve this problem i used binvalue

            IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mmoll
              wrote on last edited by
              #6

              bindValue() is indeed the more or less only correct way to proceed.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                yakine
                wrote on last edited by
                #7

                yes it's a correct way

                IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                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