#include "QSqlDatabase.h"
#include "QMessageBox.h"
#include <QSqlError>
#include <QSqlQuery>
QStringList a = QSqlDatabase::drivers();
QMessageBox::information(NULL, "", a.join("_"));
QSqlDatabase db = QSqlDatabase::addDatabase("QIBASE");
db.setHostName("localhost");
db.setUserName("sysdba");
db.setPassword("masterkey");
db.setDatabaseName("D:\\FBDatabase\\Test.fdb");
if(!db.isValid())
{
QString lastError = db.lastError().text();
QMessageBox::information(NULL, "", lastError);
}
if(!db.open())
{
QMessageBox::information(NULL, "","Error");
}
QSqlQuery qry = QSqlQuery("Select Count(*) From PERSON");
qry.exec();
qry.next();
QMessageBox::information(NULL, "", qry.value(0).toString());
QT连接FireBird测试
点赞
收藏