Results 1 to 7 of 7

Thread: QSqlQuery problem (insert once but create two rows!!!)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlQuery problem (insert once but create two rows!!!)

    When I insert a name, create two rows

    Here is insert statement
    Qt Code:
    1. void wmtDB::addEmployee(QString name)
    2. {
    3. QSqlQuery qry;
    4. qry.prepare("INSERT INTO employeestuff (name) VALUES (:name)");
    5. qry.bindValue(":name", name );
    6. if (!qry.exec())
    7. qFatal("Failed to add employee");
    8. }
    To copy to clipboard, switch view to plain text mode 

    and here the call
    Qt Code:
    1. void MainWindow::buttonOnClick()
    2. {
    3. employees.addEmployee(ui->lineEdit->text());
    4. updateEmployees();
    5. }
    To copy to clipboard, switch view to plain text mode 

    if db is empty and i run it one time with parameter "john"
    the "SELECT * FROM nameTable"
    will return
    1 "john"
    2 "john"

    please help me
    Attached Files Attached Files

Similar Threads

  1. Replies: 4
    Last Post: 11th October 2014, 14:21
  2. [pyqt] Can't insert Nulls Using QSqlQuery.execBatch
    By ftnirp in forum Qt Programming
    Replies: 0
    Last Post: 3rd October 2011, 21:07
  3. qsqlquery insert error
    By fantom in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2011, 17:15
  4. TableView + SqlQueryModel: can't insert or edit rows
    By jiveaxe in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2008, 21:55
  5. Insert rows...
    By steg90 in forum Qt Programming
    Replies: 13
    Last Post: 18th September 2007, 13:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.