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. BUG in MYSQL Plugin
QtWS25 Last Chance

BUG in MYSQL Plugin

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 812 Views
  • 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.
  • M Offline
    M Offline
    masters211
    wrote on last edited by
    #1

    Hi everyone,
    I'm tryinig to execute the following SQL query:

    QSqlQuery query;

    @
    query.prepare("INSERT INTO osoby (idosoby, Imie, Nazwisko, DataUrodzenia) "
    "VALUES (?, ?, ?, ?)");
    QString data=this->dataUrodzenia.toString();
    query.bindValue(0,999);
    query.bindValue(1,this->imie);
    query.bindValue(2,this->nazwisko);
    query.bindValue(3,this->dataUrodzenia.toString());
    query.exec();
    @

    Correct name of table is "osoby" if i type this name in query,this doesnt execute.
    If i type a name of table that doesnt exist query will execute.

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      turaz
      wrote on last edited by
      #2

      If
      @query.exec(); @

      return false, Check what return:

      @query.lastError().text();@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        masters211
        wrote on last edited by
        #3

        Both queries return no errors.
        "INSERT INTO osoby (idosoby, Imie, Nazwisko, DataUrodzenia) VALUES (?, ?, ?, ?)"

        "INSERT INTO osoby1 (idosoby, Imie, Nazwisko, DataUrodzenia) VALUES (119, 'dsf', 'dsf', 'So sty 1 2000')"

        1 Reply Last reply
        0
        • M Offline
          M Offline
          masters211
          wrote on last edited by
          #4

          I found the solution.I changed the following 2 line commands:
          QSqlQuery query; query.prepare(“INSERT INTO osuob (idosoby, Imie, ########) “ “VALUES (?, ?, ?)”);
          to this one:

          QSqlQuery query(“INSERT INTO osoby (Imie, ########, DataUrodzenia) “ “VALUES (?, ?, ?)”);
          Thanks for help

          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