Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QSqlError Class

The QSqlError class provides SQL database error information. More...

 #include <QSqlError>

Public Types

enum ErrorType { NoError, ConnectionError, StatementError, TransactionError, UnknownError }

Public Functions

QSqlError(const QString & driverText = QString(), const QString & databaseText = QString(), ErrorType type = NoError, int number = -1)
QSqlError(const QSqlError & other)
~QSqlError()
QString databaseText() const
QString driverText() const
bool isValid() const
int number() const
void setDatabaseText(const QString & databaseText)
void setDriverText(const QString & driverText)
void setNumber(int number)
void setType(ErrorType type)
QString text() const
ErrorType type() const
bool operator!=(const QSqlError & other)
QSqlError & operator=(const QSqlError & other)
bool operator==(const QSqlError & other)

Detailed Description

The QSqlError class provides SQL database error information.

A QSqlError object can provide database-specific error data, including the driverText() and databaseText() messages (or both concatenated together as text()), and the error number() and type(). The functions all have setters so that you can create and return QSqlError objects from your own classes, for example from your own SQL drivers.

See also QSqlDatabase::lastError() and QSqlQuery::lastError().

Member Type Documentation

enum QSqlError::ErrorType

This enum type describes the context in which the error occurred, e.g., a connection error, a statement error, etc.

ConstantValueDescription
QSqlError::NoError0No error occurred.
QSqlError::ConnectionError1Connection error.
QSqlError::StatementError2SQL statement syntax error.
QSqlError::TransactionError3Transaction failed error.
QSqlError::UnknownError4Unknown error.

Member Function Documentation

QSqlError::QSqlError(const QString & driverText = QString(), const QString & databaseText = QString(), ErrorType type = NoError, int number = -1)

Constructs an error containing the driver error text driverText, the database-specific error text databaseText, the type type and the optional error number number.

QSqlError::QSqlError(const QSqlError & other)

Creates a copy of other.

QSqlError::~QSqlError()

Destroys the object and frees any allocated resources.

QString QSqlError::databaseText() const

Returns the text of the error as reported by the database. This may contain database-specific descriptions; it may be empty.

See also setDatabaseText(), driverText(), and text().

QString QSqlError::driverText() const

Returns the text of the error as reported by the driver. This may contain database-specific descriptions. It may also be empty.

See also setDriverText(), databaseText(), and text().

bool QSqlError::isValid() const

Returns true if an error is set, otherwise false.

Example:

 QSqlQueryModel model;
 model.setQuery("select * from myTable");
 if (model.lastError().isValid())
     qDebug() << model.lastError();

See also type().

int QSqlError::number() const

Returns the database-specific error number, or -1 if it cannot be determined.

See also setNumber().

void QSqlError::setDatabaseText(const QString & databaseText)

Sets the database error text to the value of databaseText.

See also databaseText(), setDriverText(), and text().

void QSqlError::setDriverText(const QString & driverText)

Sets the driver error text to the value of driverText.

See also driverText(), setDatabaseText(), and text().

void QSqlError::setNumber(int number)

Sets the database-specific error number to number.

See also number().

void QSqlError::setType(ErrorType type)

Sets the error type to the value of type.

See also type().

QString QSqlError::text() const

This is a convenience function that returns databaseText() and driverText() concatenated into a single string.

See also driverText() and databaseText().

ErrorType QSqlError::type() const

Returns the error type, or -1 if the type cannot be determined.

See also setType().

bool QSqlError::operator!=(const QSqlError & other)

Compare the other error's values to this error and returns true if it is not equal.

QSqlError & QSqlError::operator=(const QSqlError & other)

Assigns the other error's values to this error.

bool QSqlError::operator==(const QSqlError & other)

Compare the other error's values to this error and returns true, if it equal.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web