//数据库使用小计
1.在pro文件中加入:QT += sql
2.如果是sqlite时出现:QSQLITE driver not loaded
解决方法:把Qt5.7.0_64\5.7\msvc2013_64\plugins\sqldrivers文件夹拷贝到执行目录
需要用到文件夹里的4个动态库
3.如果是mysql时出现:QSqlDatabase: QMYSQL driver not loaded
解决方法:下载libmysql.dll,添加到程序执行目录
4.同时使用两个数据库:
https://blog.csdn.net/qq_35130321/article/details/80284500
QSqlDatabase::addDatabase(dbType, dbName);//不能缺省数据库名
否则会报错:
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.