You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, January 3rd 2010, 1:23pm

Calling SQL Procedure

Hi! I need your help. I'm a beginner. I'd like to call SQL Procedure (MySQL) [ in the body of procedure there is for example: SELECT * FROM table; ]. I'd like to see result in QTableView. How should I do that?

It works:

void MainWindow::something()
{
queryModel = new QSqlQueryModel(table);
queryModel->setQuery("SELECT * FROM table", db);
if (queryModel -> lastError().type() != QSqlError::NoError)
DBError (queryModel -> lastError());
else
table -> setModel(queryModel);
table->show();
}

It doesn't work:

void MainWindow::something()
{
queryModel = new QSqlQueryModel(table);
queryModel->setQuery("CALL MyProcedure()", db);
if (queryModel -> lastError().type() != QSqlError::NoError)
DBError (queryModel -> lastError());
else
table -> setModel(queryModel);
table->show();
}


Please help me. It's very important for me.


Thanks
Piotr

P.S. I'm sorry for my English language.