时间:2021-07-01 10:21:17 帮助过:104人阅读
QString strdbpath("");
strdbpath = QCoreApplication::applicationDirPath();
strdbpath += "/db";
QDir dir("");
dir.mkpath(strdbpath);
strdbpath += "/mysqlite.db";
QSqlDatabase dbset = QSqlDatabase::addDatabase("QSQLITE", "file");
dbset.setDatabaseName(strdbpath);
if (!dbset.open()) {
LOG_ALL_ERROR(QStringLiteral("failed open mysqlite.db"));
return bret;
}
QSqlQuery query(QSqlDatabase::database("memory", true));
bret = query.exec("create table backlist(no varchar(100), "
"name varchar(200),color varchar(100), "
"size varchar(100), retail double, "
"discount double, unit double, "
"attrid varchar(33), salenum int, "
"backmax int, backnum int, totalprice double, "
"serial varchar(100), orderid varchar(33), "
"date varchar(100))");
QSqlQuery setquery(QSqlDatabase::database("file", true));
bret = setquery.exec("create table printset(btitle INTEGER,bshop INTEGER,bbarcode INTEGER, "
"bsellid INTEGER,bcashdesk INTEGER,bcashier INTEGER, "
"bdate INTEGER,bmemid INTEGER,bscore INTEGER, "
"bpayable INTEGER,bprivilege INTEGER,btotal INTEGER, "
"bgoodname INTEGER,bgoodcount INTEGER,bunit INTEGER, "
"bsum INTEGER,bdiscount INTEGER,bprice INTEGER, "
"bcash INTEGER,bbank INTEGER,bchange INTEGER, "
"btel INTEGER,bend INTEGER)");
1.http://blog.csdn.net/abeldeng/article/details/24767245这篇文章讲述了创建没说使用
2.qt助手
版权声明:本文为博主原创文章,未经博主允许不得转载。
实现用qt打开多个数据库
标签:qt 多个数据库