diff --git a/include/dbManager.h b/include/dbManager.h index 625eda0..6c289c8 100644 --- a/include/dbManager.h +++ b/include/dbManager.h @@ -21,7 +21,7 @@ public: QStringList conncetions();//获取所有链接名称 signals: - void errorOccurred(const QString& strConnectionName, const QSqlError& error); //错误信息信号 + void errorOccurred(const QString& strConnectionName, const QString& error); //错误信息信号 void connectionStatusChanged(const QString& strConnectionName, bool bConnected); private: diff --git a/include/mainwindow.h b/include/mainwindow.h index 5376e84..2307566 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -54,7 +54,7 @@ private slots: void onActionTrigger_removeModel(); void onSIG_addConnection(DatabaseConfig&); - void onSIG_errorFromDBManger(const QString& strConnectionName, const QSqlError& error); + void onSIG_errorFromDBManger(const QString& strConnectionName, const QString& error); void onSIG_errorFormSQLExecutor(const QString& error); void onSIG_connectionStatusChanged(const QString& strConnectionName, bool bConnected); void onSIG_addModel(Model&); diff --git a/source/dbManager.cpp b/source/dbManager.cpp index 842cc53..f149290 100644 --- a/source/dbManager.cpp +++ b/source/dbManager.cpp @@ -33,7 +33,7 @@ bool DatabaseManager::addDatabase(const DatabaseConfig& config) //QString("Connection name '%1' already exists").arg(config.strConnectionName), QString::fromWCharArray(L"已存在同名的链接: '%1'").arg(config.strConnectionName), QSqlError::ConnectionError); - emit errorOccurred(config.strConnectionName, error); + emit errorOccurred(config.strConnectionName, error.databaseText()); return false; } @@ -45,7 +45,7 @@ bool DatabaseManager::addDatabase(const DatabaseConfig& config) QSqlError error(QString::fromWCharArray(L"配置信息错误"), QString::fromWCharArray(L"'%1' 具有相同配置信息").arg(c.strConnectionName), QSqlError::ConnectionError); - emit errorOccurred(config.strConnectionName, error); + emit errorOccurred(config.strConnectionName, error.databaseText()); return false; } } @@ -62,7 +62,7 @@ bool DatabaseManager::connect(const QString& strConnectionName) QSqlError error(QString::fromWCharArray(L"配置信息错误"), QString::fromWCharArray(L"没有找到该链接的配置信息"), QSqlError::ConnectionError); - emit errorOccurred(strConnectionName, error); + emit errorOccurred(strConnectionName, error.databaseText()); LOG_ERROR("DB", QString("Connection failed: %1 due 2%").arg(strConnectionName).arg("no configuration information")); return false; } @@ -77,11 +77,11 @@ bool DatabaseManager::connect(const QString& strConnectionName) if(!db.open()) { - LOG_ERROR("DB", QString("DB: %1 open failed. connectionName: %2. error: %2") + LOG_ERROR("DB", QString("DB: %1 open failed. connectionName: %2. error: %3") .arg(config.strDBName) .arg(strConnectionName) .arg(db.lastError().databaseText())); - emit errorOccurred(strConnectionName, db.lastError()); + emit errorOccurred(strConnectionName, QString::fromWCharArray(L"数据库打开失败,详情可见日志文件")); QSqlDatabase::removeDatabase(strConnectionName); return false; } diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index 2e99c5a..bb96485 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -199,10 +199,10 @@ void MainWindow::onSIG_addConnection(DatabaseConfig& config) m_pDBStrutureModel->addConnection(config.strConnectionName, config.strDBType); } -void MainWindow::onSIG_errorFromDBManger(const QString& strConnectionName, const QSqlError& error) +void MainWindow::onSIG_errorFromDBManger(const QString& strConnectionName, const QString& error) { - m_lastSqlError = error; - showMessageDialog(type_warning, QString::fromWCharArray(L"错误"),error.databaseText()); + //m_lastSqlError = error; + showMessageDialog(type_warning, QString::fromWCharArray(L"错误"),error); } void MainWindow::onSIG_errorFormSQLExecutor(const QString& error)