Results 1 to 2 of 2

Thread: how to use database value in the variable

  1. #1
    Join Date
    Sep 2019
    Posts
    12
    Thanks
    7
    Qt products
    Qt5
    Platforms
    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
    Location
    Kraków, Poland
    Posts
    1,464
    Thanked 272 Times in 267 Posts
    Qt products
    Qt4
    Platforms
    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, 19:07
  2. Replies: 2
    Last Post: 20th October 2017, 00:25
  3. Variable variable names
    By KeineAhnung in forum Newbie
    Replies: 2
    Last Post: 22nd June 2014, 20:00
  4. Replies: 2
    Last Post: 6th April 2014, 12:07
  5. Replies: 2
    Last Post: 27th August 2012, 04:27

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.