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?
Re: Insert values into database table
Could you qDebug()<<query.lastError() after the insert and provide the output?
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:
Code:
QSqlError(-1,
"Unable to fetch row",
"No query")
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.
Re: Insert values into database table