Results 1 to 7 of 7

Thread: QSqlQuery::bindValue problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Re: QSqlQuery::bindValue problem

    Quote Originally Posted by Lesiok View Post
    But I think that after bindValue Your query looks like :
    Qt Code:
    1. SELECT 'foo' FROM myTable
    To copy to clipboard, switch view to plain text mode 
    Try look at PostgreSQL logs.


    Qt Code:
    1. SELECT 'foo' FROM myTable
    2. or
    3. SELECT foo FROM myTable
    To copy to clipboard, switch view to plain text mode 

    doesn't matter, since they work both.


    my problem is that i used
    Qt Code:
    1. QSqlQuery q(db);
    2. q.prepare("SELECT :bla FROM test");
    3. q.bindValue(":bla",someVariable);
    To copy to clipboard, switch view to plain text mode 

    in a project using qt < 4.5 to create some select queries and it doesn't work in qt 4.5 anymore, it works fine for insert statements though.

    but since a solution like
    Qt Code:
    1. query.prepare(QString("select %1 from mytable").arg("foo"));
    To copy to clipboard, switch view to plain text mode 

    works fine, i will use this. (should have done it like that in the first place)

    thanks everybody for your help.

  2. #2
    Join Date
    Jan 2006
    Posts
    132
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 16 Times in 16 Posts

    Default Re: QSqlQuery::bindValue problem

    Quote Originally Posted by segfault View Post
    Qt Code:
    1. SELECT 'foo' FROM myTable
    2. or
    3. SELECT foo FROM myTable
    To copy to clipboard, switch view to plain text mode 

    doesn't matter, since they work both.
    Yes they both work, but they do different things of course.

    The first will always return the text foo, no matter what is actually in the table, and the second will return the content of the column with name foo.

  3. #3
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default Re: QSqlQuery::bindValue problem

    Quote Originally Posted by seneca View Post
    Yes they both work, but they do different things of course.

    The first will always return the text foo, no matter what is actually in the table, and the second will return the content of the column with name foo.
    i know sorry, i just wanted to point out that i would be happy with either of them, instead of the error i got

Similar Threads

  1. Compilation problem with QSqlQuery::bindValue()
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2013, 23:30
  2. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 13:48
  3. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 10:12
  4. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 09:47
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.