The QSqlError class provides SQL database error information. 更多...
头: | #include <QSqlError> |
qmake: | QT += sql |
enum | ErrorType { NoError, ConnectionError, StatementError, TransactionError, UnknownError } |
QSqlError (const QString & driverText = QString(), const QString & databaseText = QString(), ErrorType type = NoError, const QString & code = QString()) | |
QSqlError (const QSqlError & other ) | |
~QSqlError () | |
QString | databaseText () const |
QString | driverText () const |
bool | isValid () const |
QString | nativeErrorCode () const |
QString | text () const |
ErrorType | type () const |
bool | operator!= (const QSqlError & other ) const |
QSqlError & | operator= (const QSqlError & other ) |
bool | operator== (const QSqlError & other ) const |
The QSqlError class provides SQL database error information.
A QSqlError object can provide database-specific error data, including the driverText () 和 databaseText () messages (or both concatenated together as text ()), and the nativeErrorCode () 和 type ().
另请参阅 QSqlDatabase::lastError () 和 QSqlQuery::lastError ().
This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.
常量 | 值 | 描述 |
---|---|---|
QSqlError::NoError
|
0
|
没有出现错误。 |
QSqlError::ConnectionError
|
1
|
Connection error. |
QSqlError::StatementError
|
2
|
SQL statement syntax error. |
QSqlError::TransactionError
|
3
|
Transaction failed error. |
QSqlError::UnknownError
|
4
|
Unknown error. |
Constructs an error containing the driver error text driverText , the database-specific error text databaseText , the type type and the error code code .
创建副本为 other .
销毁对象并释放任何分配资源。
Returns the text of the error as reported by the database. This may contain database-specific descriptions; it may be empty.
另请参阅 setDatabaseText (), driverText (),和 text ().
Returns the text of the error as reported by the driver. This may contain database-specific descriptions. It may also be empty.
另请参阅 setDriverText (), databaseText (),和 text ().
返回
true
if an error is set, otherwise false.
范例:
QSqlQueryModel model; model.setQuery("select * from myTable"); if (model.lastError().isValid()) qDebug() << model.lastError();
另请参阅 type ().
Returns the database-specific error code, or an empty string if it cannot be determined.
This is a convenience function that returns databaseText () 和 driverText () concatenated into a single string.
另请参阅 driverText () 和 databaseText ().
Returns the error type, or -1 if the type cannot be determined.
另请参阅 setType ().
Compare the
other
error's values to this error and returns
true
if it is not equal.
赋值 other error's values to this error.
Compare the
other
error's values to this error and returns
true
, if it equal.