Results 1 to 10 of 10

Thread: Problem with QSqlQuery and the .arg of a QString[SOLVED]

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QSqlQuery and the .arg of a QString

    The single quote around the name is missing in the second code block. Try this

    Qt Code:
    1. //Note: CSQLUsers::AL_PUPIL is "1", an intenger
    2.  
    3. QString name = 'Alex';
    4. QSqlQuery data(QString("SELECT id FROM users WHERE iaccesslevel=%1 AND sname = '%2' ") .arg(CSQLUsers::AL_PUPIL) .arg(name), *pointer_my_database->GetDBPtr());
    5.  
    6. bool test1 = data.first();
    7. bool test2 = data.isValid();
    8. bool test3 = data.isSelect();
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to munna for this useful post:

    jano_alex_es (5th May 2009)

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
  •  
Qt is a trademark of The Qt Company.