QSqlError Class

QSqlError 클래스는 SQL 데이터베이스 오류 정보를 제공합니다. 더 보기...

Header: #include <QSqlError>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
qmake: QT += sql

공용 타입

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

이 열거형 유형은 오류가 발생한 컨텍스트(예: 연결 오류, 문 오류 등)를 설명합니다.

Constant설명
QSqlError::NoError0오류가 발생하지 않았습니다.
QSqlError::ConnectionError1연결 오류입니다.
QSqlError::StatementError2SQL 문 구문 오류입니다.
QSqlError::TransactionError3트랜잭션 실패 오류입니다.
QSqlError::UnknownError4알 수 없는 오류입니다.

멤버 함수 문서

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)

Move는 other 이 가리키고 있던 것과 동일한 객체를 가리키도록 QSqlError 인스턴스를 생성합니다.

참고: 이동한 개체 other 는 부분적으로 형성된 상태로 배치되며, 유효한 작업은 소멸과 새 값 할당뿐입니다.

[noexcept] QSqlError::~QSqlError()

개체를 파괴하고 할당된 모든 리소스를 해제합니다.

QString QSqlError::databaseText() const

데이터베이스에서 보고한 오류의 텍스트를 반환합니다. 여기에는 데이터베이스별 설명이 포함될 수 있으며 비어 있을 수도 있습니다.

driverText() 및 text()도 참조하세요 .

QString QSqlError::driverText() const

드라이버가 보고한 오류의 텍스트를 반환합니다. 여기에는 데이터베이스별 설명이 포함될 수 있습니다. 비어 있을 수도 있습니다.

databaseText() 및 text()도 참조하세요 .

bool QSqlError::isValid() const

오류가 설정되어 있으면 true, 그렇지 않으면 false를 반환합니다.

예시:

QSqlQueryModel model; 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()를 하나의 문자열로 연결하여 반환하는 편의 함수입니다.

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)

이동 - other 을 이 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.