[Solved]Problem using QSqlTableModel with QOCI



  • I've tried to use a QSqlTableModel with QOCI, but the select function does nothing (no data gets the model). Is it a bug or I've missed something?
    I've tried with QODBC and works perfectly.
    This is the code:

    @db=QSqlDatabase::addDatabase("QODBC");
    db.setDatabaseName(bbdd);
    db.setUserName(usuario);
    db.setPassword(contrasena);
    if(!db.open())
    {
    QMessageBox::warning(this, tr("Error Conexion"), tr("Error al abrir la base de datos."), QMessageBox::Ok);
    emit salir();
    }@

    Thanks for your help.



  • Hi
    but you not provide code where you try select something from database?
    please provide this part of code.
    also use
    OraConnect.lastError().databaseText()
    OraConnect.lastError().driverText();
    for more informative message

    good luck



  • Thanks for replying so fast.
    This is how I make the select:
    @QSqlTableModel *model2 = new QSqlTableModel(0,db);
    model2->setTable("INOPTI_TOPOLOGY");
    model2->select();
    ui->tabla->setModel(model2);
    ui->tabla->show();@

    It's very strange, finally I had to use a QSqlQueryModel (that works perfectly), but it's more limited than QSqlTableModel.
    I'll see what I get from lastError.

    Thank you!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.