QSqlQuery.exec() weird error
Hi to all!
I am trying to acces MySQL database via MySQL Odbc connector. I've setup following code:
Code:
DataBrowserBaseClass
::DataBrowserBaseClass(QWidget *parent,
const QString& strTableNAme,
QSqlDatabase& sourceDb)
{
createMembers(); // create member objects
if(sourceDb.open())
{
// db opened ok
if(queryTablesList()->exec())
{
// query exec ok
while(queryTablesList()->next())
{
tablesList()->append(queryTablesList()->value(0).toString());
} // while
}
else
{
// query exec error, handle it
sourceDb.close(); // closes connection to database
} // if
}
else
{
// db open error handler
}
}
and I get following error:
Quote:
"QODBCResult::exec: No statement handle available" Error: " "
What does this mean? What am I doing wrong?
Sincerely,
Marko
Re: QSqlQuery.exec() weird error
I would guess one of the functions of yours that you call are incorrect.
Re: QSqlQuery.exec() weird error
Well, how can I then get list of tables inside database? I did this:
Code:
m_pQueryTablesList
=new QSqlQuery("SHOW TABLES",
sourceDb);
Q_ASSERT_X(queryTablesList()!=0,
"Table list query allocation",
"Table list query could not be allocated.");
If I enter identical command into MySQL command line, I get list ok.
Re: QSqlQuery.exec() weird error
Please provide a minimal compilable example reproducing the problem. Please also remember you are using ODBC to access the database not the native MySQL driver for Qt.