QT problem of link to database



  • I decided to change the vindu and toss two minGW files and a project file. After the change, he put qt and put these two files as usual. It all came down and worked, but problems started with the bd connection (before it was normal and worked).

    Mistakes:

    QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work. QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.

    In the code, there's a check on the bad launch, it doesn't work as if he sees the problem not in the location of the file.

    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("database_link1.db");
    db.open();
    if(!db.open())
    {
        QMessageBox::warning(this, "OOPS", "База данных не открыта!");
    }
    


  • You're twice an O.D. that's what the barnings say.

    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("database_link1.db");
    //db.open(); - это не нужно
    if(!db.open())
    {
        QMessageBox::warning(this, "OOPS", "База данных не открыта!");
    }
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2