页: 1 C++
I m试图与ODBC db连接,但Im获得以下产出:
QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE
How do Iload ODBC
in Qt
。
CODE :
QString serverName = "LOCALHOST\SQLEXPRESS";
QString dbName = "test";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setConnectionOptions();
QString myCon = QString("DRIVER={SQL Native Client};SERVER=%1;DATABASE=%2;Trusted_Connection = Yes").arg(serverName).arg(dbName);
db.setDatabaseName(myCon);
if(db.open())
{
qDebug() << "Opened!";
db.close();
}
else
{
qDebug() << "Error : " << db.lastError().text();
}
我试图在网上跟踪这些步骤,但令人非常困惑。
谁能让我采取简化做法来这样做?