PDA

View Full Version : QSqlQuery.exec() weird error



MarkoSan
25th May 2010, 11:46
Hi to all!

I am trying to acces MySQL database via MySQL Odbc connector. I've setup following code:
DataBrowserBaseClass::DataBrowserBaseClass(QWidget *parent,
const QString& strTableNAme,
QSqlDatabase& sourceDb)
: QWidget(parent)
{
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:
"QODBCResult::exec: No statement handle available" Error: " "What does this mean? What am I doing wrong?

Sincerely,
Marko

wysota
25th May 2010, 12:20
I would guess one of the functions of yours that you call are incorrect.

MarkoSan
25th May 2010, 12:23
Well, how can I then get list of tables inside database? I did this:
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.

wysota
25th May 2010, 14:02
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.