Results 1 to 3 of 3

Thread: QSqlQuery::bndvalue()

  1. #1
    Join Date
    Apr 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QSqlQuery::bndvalue()

    hello guys can anyone help me out i have a ui dialog that i want users to enter their details and then that data they give is inserted into the database only problem is when i run this code no data is shown in the database although it shows that a new record was inserted.
    this is the code:

    QSqlQuery qry;
    qry.prepare("INSERT INTO [oilsoft].[dbo].[EmployeeStatistics]([EmployeeId],[FirstName],[SirName],[LastName],[Department],[BasicSalary],[Allowances],[NHIF],[NSSF],[Other],[PAYE])VALUES(:EmployeeId,:FirstName,:SirName,:LastName,epartment,:BasicSalary,:Allowances,:NHIF,:NSSF,:Ot her,:PAYE)");
    qry.bindValue(":EmployeeId",ui->employeeIdlineEdit->text());
    qry.bindValue(":FirstName",ui->firstnamelineEdit->text());
    qry.bindValue(":SirName",ui->sirnamelineEdit->text());
    qry.bindValue(":LastName",ui->lastnamelineEdit->text());
    qry.bindValue("epartment",ui->departmentlineEdit->text());
    qry.bindValue(":BasicSalary",ui->basicsalarylineEdit->text());
    qry.bindValue(":Allowances",ui->allowanceslineEdit->text());
    qry.bindValue(":NHIF",ui->nhiflineEdit->text());
    qry.bindValue(":NSSF",ui->nssflineEdit->text());
    qry.bindValue(":Other",ui->otherlineEdit->text());
    qry.bindValue(":PAYE",ui->payelineEdit->text());
    qry.exec();

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlQuery::bndvalue()

    Check if all those line edits contain proper values.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlQuery::bndvalue()

    It seems unlikely that a column named "BasicSalary" or "Allowances" is a VARCHAR (string) column.

    You should also get into the habit of checking that your QSqlQuery::exec() calls succeed, i.e. return true, and if not looking at the QSqlQuery::lastError().

Similar Threads

  1. Replies: 1
    Last Post: 18th July 2011, 12:12
  2. Using QSqlQuery
    By darkman_dev in forum Newbie
    Replies: 2
    Last Post: 4th February 2011, 21:40
  3. QSqlQuery
    By yasher in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2010, 14:25
  4. QSqlquery
    By codeman in forum Qt Programming
    Replies: 10
    Last Post: 4th June 2009, 12:57
  5. what is going on a QSqlQuery?
    By mismael85 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2008, 13:35

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.