#include <QCoreApplication> #include <Qtsql> #include <QtDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSqlDatabase db=QSqlDatabase::addDatabase("QODBC"); db.setDatabaseName("testodbc"); db.setUserName("sa"); db.setPassword("scada"); if(db.open()) { qDebug()<<"opened"; } else { qDebug()<<"ERROR="<<db.lastError().text(); } return a.exec(); }
时间: 2024-12-22 11:37:01