QSqlError Class
QSqlError クラスは SQL データベースエラー情報を提供します。詳細...
ヘッダ | #include <QSqlError> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Sql) target_link_libraries(mytarget PRIVATE Qt6::Sql) |
qmake: | QT += sql |
- 継承メンバを含む全メンバのリスト
- QSqlError はデータベースクラスの一部です。
パブリックタイプ
enum | ErrorType { NoError, ConnectionError, StatementError, TransactionError, UnknownError } |
パブリック関数
QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString()) | |
QSqlError(const QSqlError &other) | |
QSqlError(QSqlError &&other) | |
~QSqlError() | |
QString | databaseText() const |
QString | driverText() const |
bool | isValid() const |
QString | nativeErrorCode() const |
void | swap(QSqlError &other) |
QString | text() const |
QSqlError::ErrorType | type() const |
bool | operator!=(const QSqlError &other) const |
QSqlError & | operator=(QSqlError &&other) |
QSqlError & | operator=(const QSqlError &other) |
bool | operator==(const QSqlError &other) const |
詳細説明
QSqlError オブジェクトは、driverText() およびdatabaseText() メッセージ (または両方を連結したtext()) や、nativeErrorCode() およびtype() など、データベース固有のエラー データを提供できます。
QSqlDatabase::lastError() およびQSqlQuery::lastError()も参照 。
メンバ型ドキュメント
enum QSqlError::ErrorType
この列挙型は、接続エラーやステートメントエラーなど、エラーが発生したコンテキストを記述します。
定数 | 値 | 説明 |
---|---|---|
QSqlError::NoError | 0 | エラーは発生しませんでした。 |
QSqlError::ConnectionError | 1 | 接続エラー。 |
QSqlError::StatementError | 2 | SQL 文構文エラー。 |
QSqlError::TransactionError | 3 | トランザクション失敗エラー。 |
QSqlError::UnknownError | 4 | 不明なエラー |
メンバ関数ドキュメント
QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString())
ドライバー・エラー・テキストdriverText 、データベース固有のエラー・テキストdatabaseText 、タイプtype 、エラー・コードcode を含むエラーを構築する。
QSqlError::QSqlError(const QSqlError &other)
other のコピーを作成する。
[noexcept]
QSqlError::QSqlError(QSqlError &&other)
移動-QSqlError インスタンスを構築し、other が指していたのと同じオブジェクトを指すようにします。
注意: 移動元のオブジェクトother は部分的に形成された状態に置かれ、この状態では有効な操作は破棄と新しい値の割り当てのみです。
[noexcept]
QSqlError::~QSqlError()
オブジェクトを破棄し、割り当てられたリソースを解放する。
QString QSqlError::databaseText() const
データベースから報告されたエラーのテキストを返します。これにはデータベース固有の説明が含まれることもありますし、空であることもあります。
driverText() およびtext()も参照 。
QString QSqlError::driverText() const
ドライバが報告したエラーのテキストを返します。これにはデータベース固有の説明が含まれることがあります。また、空の場合もあります。
databaseText() およびtext()も参照 。
bool QSqlError::isValid() const
エラーが設定されていればtrue
を返し、そうでなければ false を返す。
例
QSqlQueryModelmodel; model.setQuery("select * from myTable");if(model.lastError().isValid()) qDebug() << model.lastError();
type()も参照のこと 。
QString QSqlError::nativeErrorCode() const
データベース固有のエラーコードを返すか、判断できない場合は空文字列を返す。
注意: いくつかのドライバ (DB2 や ODBC など) は複数のエラーコードを返すことがあります。このような場合は、;
をエラーコードの区切り文字として使用します。
[noexcept]
void QSqlError::swap(QSqlError &other)
このエラーをother と入れ替える。この操作は非常に速く、失敗することはない。
QString QSqlError::text() const
これは、databaseText() とdriverText() を1つの文字列に連結して返す便利な関数である。
driverText() およびdatabaseText()も参照のこと 。
QSqlError::ErrorType QSqlError::type() const
エラーの種類を返し、種類が特定できない場合は -1 を返す。
bool QSqlError::operator!=(const QSqlError &other) const
other エラーのtype() とnativeErrorCode() をこのエラーと比較し、等しくなければtrue
を返す。
[noexcept]
QSqlError &QSqlError::operator=(QSqlError &&other)
Move-assignother をこのQSqlError インスタンスに割り当てる。
注: 移動元のオブジェクトother は、部分的に形成された状態に置かれる。この状態では、有効な操作は破壊と新しい値の割り当てのみである。
QSqlError &QSqlError::operator=(const QSqlError &other)
other エラーの値をこのエラーに割り当てる。
bool QSqlError::operator==(const QSqlError &other) const
other エラーのtype() とnativeErrorCode() をこのエラーと比較し、等しければtrue
を返す。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.