QT连接FireBird测试
程序员文章站
2024-03-16 18:41:46
...
#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());
转载于:https://my.oschina.net/hemiya/blog/189674
下一篇: 三维空间三角形与线段相交判断
推荐阅读