PDA

View Full Version : StoredProcedure ProgressDilaog



LordQt
17th March 2009, 13:08
Hello friends,

How can I indicate a progressbar during a stored procedure on mssql.

my code is this



void TableEditor::startProc1()
{
QSqlQuery q;
QString stmt="{CALL procName1('05.03.2009','12.03.2009')}";
q.setForwardOnly(true);
q.prepare(stmt);
int i(0);

if(!(i=q.exec()))
{
qCritical()<<q.lastError().text();
}
else if(!q.first())
{
qCritical()<<q.lastError().text();
}
qDebug()<<q.record();
QString strvalue;
strvalue=QString::number(i);

QMessageBox::information(this, tr("Procedure finished"),
tr("Returnvalue: %1 "
" ")
.arg(strvalue));
}


My Procedure on the mssql database takes a few minute and I would implement a visual feddback with a progressbar but don´t know how to implement it with stored procedure??
Have anybody an idea????

rossd
17th March 2009, 15:25
The length of the delay is a function of the complexity of the query and the size of the data set you are dealing with -- a database issue. You would need some sort of functionality in your database that would execute a callback and I know of no such functionality.

The practical answer is to set the cursor to wait while the query executes.

No as 'pretty' perhaps, but easily done.

LordQt
19th March 2009, 13:02
What do you mean I have to set the cursor during executing. Have you any example??

I try this



void TableEditor::startProc1()
{
prgBarDialog = new QProgressDialog;
prgBarDialog->setMaximum(1000);
QSqlQuery q;
QString stmt="{CALL procName1('05.03.2009','12.03.2009')}";
q.setForwardOnly(true);
q.prepare(stmt);
int i(0);
QString barText="blubber";
prgBarDialog->setLabelText(tr("Executing Procedure %1...").arg(barText));
prgBarDialog->setWindowModality(Qt::WindowModal);
prgBarDialog->setValue(20);
if(!(i=q.exec()))
{
qCritical()<<q.lastError().text();
}
else if(!q.first())
{
qCritical()<<q.lastError().text();
}
prgBarDialog->setValue(1000);
}

the progressdialog shows itself up but during executing it seems the dialog is freezing after executing it shows the progressbar from left to right in 200 mph ;

So whats up with the cursor? Where to put those cursor....?