Results 1 to 4 of 4

Thread: Insert values into database table

  1. #1
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Insert values into database table

    I have two classes: one is my MainWindow in which I create connection to database, other one is a QDialog from which I want insert new rows into the database table.
    QDialog is called form inside of MainWindow (through menu).
    Problem is the QDialog don't seems to see the database connection created by MainWindow.
    How can I make the db wisible to QDialog?

    you can view my code here: http://code.google.com/p/neurohelper...e/#svn%2Ftrunk
    MainWindow: http://code.google.com/p/neurohelper...mainwindow.cpp
    QDialog: http://code.google.com/p/neurohelper...userdialog.cpp

    Any help?
    BlogBits | YouTube | Flickr | MAL | Last.fm | Web Profile
    CLI is not an UI, it's a way of life!

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert values into database table

    Could you qDebug()<<query.lastError() after the insert and provide the output?

  3. #3
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert values into database table

    I did it myself and discovered that problem lied within query. Shame on me.
    But now I have similiar problem. My central widget inside main window contains other widgets. How many widgets are added to central widget depends on how many rows I have in primary table inside my database. Problem is that when i try to execute query from within my central widget query.exec() returns false. lastError() from query is:
    Qt Code:
    1. QSqlError(-1, "Unable to fetch row", "No query")
    To copy to clipboard, switch view to plain text mode 

    You can look at code of my central widget here: http://code.google.com/p/neurohelper...playergrid.cpp

    Connection to database is created by Main Window.

    Edit: and again problem lied somewhere within the query.
    Last edited by l0ner; 20th June 2011 at 19:08. Reason: resolved
    BlogBits | YouTube | Flickr | MAL | Last.fm | Web Profile
    CLI is not an UI, it's a way of life!

  4. #4
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Insert values into database table


Similar Threads

  1. Replies: 4
    Last Post: 10th May 2011, 13:19
  2. unable to insert into table
    By mohanakrishnan in forum Qt Programming
    Replies: 0
    Last Post: 4th December 2009, 11:52
  3. Updating Table Values.
    By kenny_isles in forum Newbie
    Replies: 14
    Last Post: 13th February 2007, 12:04
  4. how to insert an ' in a database
    By jh in forum General Programming
    Replies: 3
    Last Post: 17th August 2006, 03:47
  5. adding in values to table
    By therealjag in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2006, 17:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.