Results 1 to 8 of 8

Thread: Qt Check if there is an open database connection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 106 Times in 103 Posts

    Default Re: Qt Check if there is an open database connection

    You're showing wrong part of your code.
    Error is generated by the part that executes a query not sets up the database.

    You're probably not using connection name there.
    When creating the query you have to specify which connection you want to use:
    Qt Code:
    1. QSqlQuery query( QSqlDatabase::database( "StockManagerConn" ) );
    To copy to clipboard, switch view to plain text mode 
    otherwise it will fall back on the default name and fail.

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

    ShapeShiftme (17th February 2012)

Similar Threads

  1. Check network connection
    By sophister in forum Qt Programming
    Replies: 8
    Last Post: 3rd September 2012, 12:00
  2. [SOLVED] database opened .. database not open
    By kapitanluffy in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2011, 10:39
  3. Replies: 1
    Last Post: 2nd April 2010, 06:42
  4. Check if a table exists in a mysql database
    By graciano in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2009, 02:44
  5. database connection
    By peace_comp in forum Qt Programming
    Replies: 4
    Last Post: 13th May 2008, 12:16

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.