Results 1 to 10 of 10

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

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

    On the other hand, the next code:

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

    gives me false, false and true again :S

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Why You have

    Qt Code:
    1. QString name = 'Alex';
    To copy to clipboard, switch view to plain text mode 

    not

    Qt Code:
    1. QString name = "Alex";
    To copy to clipboard, switch view to plain text mode 

    ???

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

    jano_alex_es (5th May 2009)

  4. #3
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

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

    Because I was testing, testing, testing and testing, and I though "maybe the problem is in the double-mark, SQL uses simple so let's try". The compiler said nothing, I though it was the same.

    Thanks, definitly your solutions were right and the last problem was that.

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

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

    Quote Originally Posted by jano_alex_es View Post
    The compiler said nothing, I though it was the same.
    I see someone is using a lousy... eee.... Microsoft compiler.
    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.


  6. #5
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

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

    what can I say, the company chooses the compiler :P

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.