How does one connect a database pointer to a sqlquery pointer. For example,
Qt Code:
To copy to clipboard, switch view to plain text mode
How does one connect a database pointer to a sqlquery pointer. For example,
Qt Code:
To copy to clipboard, switch view to plain text mode
QSqlQuery does not have a constructor taking a QSqlDatabase* so you cannot do what you ask. Also, QSqlDatabase::addDatabase() returns a QSqlDatabase, so there is no need to do anything else to the return value.
What you want to do, after you have read the docs and looked at the examples (which show this pattern over and over) is:
Qt Code:
db.setDatabaseName("/some/file/path"); // you might need credentials for other database types if (db.open()) { qry.prepare(...); // etc. }To copy to clipboard, switch view to plain text mode
zim (3rd July 2011)
Bookmarks