Home > Mobile >  Total failure when Qt5.7 connection Access database, open! Why is that?
Total failure when Qt5.7 connection Access database, open! Why is that?

Time:01-21

MainWindow: : MainWindow (QWidget * parent) :
QMainWindow (parent),
UI (new UI: : MainWindow)
{
The UI - & gt; SetupUi (this);

QStringList strList=QSqlDatabase: : drivers ();
Foreach (QString STR, strList)
QDebug () & lt; & lt;" \ t "& lt; /* this output:
* "QSQLITE"
* "QMYSQL"
* "QMYSQL3
"* "QODBC"
* "QODBC3
"* "QPSQL
"* "QPSQL7
"*/
The db=QSqlDatabase: : addDatabase (" QODBC ");
QDebug () & lt; & lt;" Loading ODBC Driver success?" QString DSN="DRIVER={Microsoft Access DRIVER (*. MDB, *. Accdb)}; FIL={MS Access}; DBQ=E: \ \ Database2 MDB ".
Db. SetDatabaseName (DSN);
Bool isOK=db. The open ();
QDebug () & lt; if(! IsOK)
{
QMessageBox: : critical (0, tr (" open the database error "), the tr (" cannot establish a database connection \ n "), QMessageBox: : Cancel);

}

CodePudding user response:

The building Lord solved? I also encountered this problem, the solution is
  •  Tags:  
  • Qt
  • Related