Results 1 to 6 of 6

Thread: Problem Executing Query from QT

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem Executing Query from QT

    First of all thanks for the support.

    Ya i know that theres some syntax error in the query but I'm not able to figure it out as i can run the same query successfully from the terminal. Anyways, I'm posting the relevant lines of code below :

    Qt Code:
    1. QSqlQuery query(mRemoteDB);
    2.  
    3. QString queryStr = QString("SELECT nsdqaohlcv.open, nsdqaohlcv.hightime, nsdqaohlcv.high, nsdqaohlcv.lowtime, nsdqaohlcv.low, nsdqaohlcv.close, nsdqaohlcv.volume, nsdqaohlcv.trades FROM \"nsdqaohlcv\", \"stock\", \"calendar\" WHERE nsdqaohlcv.stock_id = stock.stock_id AND nsdqaohlcv.date_id = calendar.date_id AND stock.symbol = '%1' AND calendar.date = ( SELECT MAX(date) FROM \"calendar\" WHERE EXTRACT (DOW FROM date) >= 1 AND EXTRACT(DOW FROM date) <= 5 AND date < 'today' AND isholiday IS NULL)").arg(mStockname);
    4.  
    5. bool retVal = query.exec(queryStr);
    6.  
    7. if(!retVal){
    8. QString errMsg = QString( "Error executing query: %1\n"
    9. "Error Message from Database: %2"
    10. ).arg(queryStr).arg(query.lastError().text());
    11. mpError->setMessage(errMsg, Error::Critical);
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 20th May 2011 at 10:47.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Problem Executing Query from QT

    SQL uses single quotes to delimit strings not double quotes.


    Edit: I reread the query. Disregard this comment.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    May 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem Executing Query from QT

    I just remover the double quotes from the table names but still the query does not gets executed

Similar Threads

  1. long query executing
    By banita in forum Qt Programming
    Replies: 11
    Last Post: 11th October 2010, 01:38
  2. problem while executing SQL query
    By sosanjay in forum Qt Programming
    Replies: 3
    Last Post: 9th October 2009, 13:52
  3. problem while executing Query
    By jjbabu in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2009, 12:46
  4. Error executing SELECT query with QSQLITE
    By garfield85 in forum Qt Programming
    Replies: 6
    Last Post: 25th May 2009, 19:05
  5. A problem with executing Qt 4.5.0
    By Dante in forum Installation and Deployment
    Replies: 20
    Last Post: 15th March 2009, 20:50

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.