Results 1 to 2 of 2

Thread: how to use database value in the variable

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2019
    Qt products
    MacOS X

    Default how to use database value in the variable

    Qt Code:
    1. QString timess;
    2. QSqlQuery qry;
    3. qry.prepare("SELECT FROM test WHERE time = '"+timess+"'");
    4. if (qry.exec()){
    5. ui->time->setText(timess);
    6. qDebug("timess");
    7. };
    To copy to clipboard, switch view to plain text mode 

    This is my code. after I Run ui didn't show anything.

    I create timess with qstring and store the time value from database(SQLite) into it's.
    But in the time ui (QLable) didn't show anything after I run the process.

  2. #2
    Join Date
    Mar 2008
    Kraków, Poland
    Thanked 275 Times in 270 Posts
    Qt products
    Unix/X11 Windows

    Default Re: how to use database value in the variable

    1. SQL query is incorrect - You must indicate what you want select.
    2. Read about QSqlQuery::next and QSqlQuery::value.

  3. The following user says thank you to Lesiok for this useful post:

    akkarachai (3rd December 2019)

Similar Threads

  1. Replies: 3
    Last Post: 6th February 2019, 18:07
  2. Replies: 2
    Last Post: 19th October 2017, 23:25
  3. Variable variable names
    By KeineAhnung in forum Newbie
    Replies: 2
    Last Post: 22nd June 2014, 19:00
  4. Replies: 2
    Last Post: 6th April 2014, 11:07
  5. Replies: 2
    Last Post: 27th August 2012, 03:27


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.