qt4中连接mysql出现Cannot open include file: 'QSqlError': No such file or directory
qt4中连接mysql数据库头文件中有#include<QtSql\QSqlDatabase>#include<QtGui>#include<QMessageBox>//...
qt4中连接mysql数据库头文件中有
#include <QtSql\QSqlDatabase>
#include <QtGui>
#include <QMessageBox>
//#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
调用下面函数时
void CfgLog4cxxDialogImpl::open()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("cbz8600");
db.setUserName("root");
db.setPassword("root");
if(!db.open()){
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());
}
//连接成功执行查询
QSqlQuery query;
query.exec("select * from family");
while (query.next()) {
QString name = query.value(2).toString();
QString code = query.value(1).toString();
QMessageBox::information(0,code,name);
}
}
出现错误1>.\cfglog4cxxdialogimpl.cpp(11) : fatal error C1083: Cannot open include file: 'QSqlError': No such file or directory 展开
#include <QtSql\QSqlDatabase>
#include <QtGui>
#include <QMessageBox>
//#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
调用下面函数时
void CfgLog4cxxDialogImpl::open()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("cbz8600");
db.setUserName("root");
db.setPassword("root");
if(!db.open()){
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());
}
//连接成功执行查询
QSqlQuery query;
query.exec("select * from family");
while (query.next()) {
QString name = query.value(2).toString();
QString code = query.value(1).toString();
QMessageBox::information(0,code,name);
}
}
出现错误1>.\cfglog4cxxdialogimpl.cpp(11) : fatal error C1083: Cannot open include file: 'QSqlError': No such file or directory 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询