Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Problem using QSqlTableModel with QOCI
Forum Updated to NodeBB v4.3 + New Features

[Solved]Problem using QSqlTableModel with QOCI

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BelenMuñoz
    wrote on last edited by
    #1

    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.

    Me casé con un enano pa jartarme de reí.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Galbarad
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BelenMuñoz
        wrote on last edited by
        #3

        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!!

        Me casé con un enano pa jartarme de reí.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved