synpro85
26th May 2014, 15:41
Hello
I have a question to ask hoping someone can help me ....
I access from my application to a Postgres database. I have to make a call to a function with parameters on the DB that returns two cursors and then display the data in a tableView. I will return errors and I wonder if QT with a call of this type is supported.
This is mycode:
QSqlQuery qdb1(db);
int iSr=0;
QString stGeom,stImage,stVideo,stDateFrom,stDateTo;
iSr= ui->comboBoxSr->currentIndex();
stGeom="";
stImage="";
stVideo="";
stDateFrom="";
stDateTo="";
// c1 and c2 are dbcursor
qdb1.prepare("select * from f_get_data('c1', 'c2', ?, ?, ?, ?, ?, ?);fetch all in c1;fetch all in c2;");
qdb1.bindValue(0, iSr);
qdb1.bindValue(1, stGeom);
qdb1.bindValue(2, stImage);
qdb1.bindValue(3, stVideo);
qdb1.bindValue(4, stDateFrom);
qdb1.bindValue(5, stDateTo);
qdb1.setForwardOnly(true);
if(qdb1.exec()){
QSqlQueryModel *model1 = new QSqlQueryModel;
model1->setQuery(qdb1);
ui->tableViewMissionPlan->setModel(model1);
ui->tableViewMissionPlan->show();
}
Thank's a lot
I have a question to ask hoping someone can help me ....
I access from my application to a Postgres database. I have to make a call to a function with parameters on the DB that returns two cursors and then display the data in a tableView. I will return errors and I wonder if QT with a call of this type is supported.
This is mycode:
QSqlQuery qdb1(db);
int iSr=0;
QString stGeom,stImage,stVideo,stDateFrom,stDateTo;
iSr= ui->comboBoxSr->currentIndex();
stGeom="";
stImage="";
stVideo="";
stDateFrom="";
stDateTo="";
// c1 and c2 are dbcursor
qdb1.prepare("select * from f_get_data('c1', 'c2', ?, ?, ?, ?, ?, ?);fetch all in c1;fetch all in c2;");
qdb1.bindValue(0, iSr);
qdb1.bindValue(1, stGeom);
qdb1.bindValue(2, stImage);
qdb1.bindValue(3, stVideo);
qdb1.bindValue(4, stDateFrom);
qdb1.bindValue(5, stDateTo);
qdb1.setForwardOnly(true);
if(qdb1.exec()){
QSqlQueryModel *model1 = new QSqlQueryModel;
model1->setQuery(qdb1);
ui->tableViewMissionPlan->setModel(model1);
ui->tableViewMissionPlan->show();
}
Thank's a lot