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

prepare functions fails.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 494 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.
  • B Offline
    B Offline
    britsfp
    wrote on last edited by
    #1

    Hello all;
    I have this prepare function that refuses to co-operate, any help
    I have been reading docs and websites all day .... even tried my son for help.

    the code is::

    test1 = qry.prepare("INSERT INTO histories (datum, hsname, dist)" " VALUES (:histStr[1], :histStr[0], :histInt[0])");

    qry.bindValue(":datum", histStr[1]);
    qry.bindValue(":hsname", histStr[0]);
    qry.bindValue(":dist", histInt[0]);

    where test1 is a bool that remains false.

    Regards.
    Frik Brits

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by JKSH
      #2

      Hi and welcome to the forums
      The last part looks odd
      " VALUES (:histStr[1], :histStr[0], :histInt[0])");
      You should use the bind variable names and not real variable name ( the var where values in )

      QSqlQuery query;
      query.prepare("INSERT INTO person (id, forename, surname) VALUES (:id, :forename, :surname)");
      query.bindValue(":id", 1001);
      query.bindValue(":forename", "Bart");
      query.bindValue(":surname", "Simpson");
      query.exec();
      
      1 Reply Last reply
      4
      • B Offline
        B Offline
        britsfp
        wrote on last edited by
        #3

        Hello "mrjj",
        Ahhh and there the lights come on for me too :)
        Thank you so much.

        I am a little of a newbie with this bindValue(); but now I get it I think.

        Regards
        Frik Brits

        1 Reply Last reply
        1

        • Login

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