summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/tds/qsql_tds.cpp
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2009-11-04 03:23:58 (GMT)
committerBill King <bill.king@nokia.com>2009-11-04 03:29:27 (GMT)
commit064383eba647c2729e283f68db2394cb6a8df0c3 (patch)
treeac7de8e05d26ada280d3b34ed07e8e1037a0fec7 /src/sql/drivers/tds/qsql_tds.cpp
parent9f30be82b42c7b29236067ec819dc037d7d648dd (diff)
downloadQt-064383eba647c2729e283f68db2394cb6a8df0c3.zip
Qt-064383eba647c2729e283f68db2394cb6a8df0c3.tar.gz
Qt-064383eba647c2729e283f68db2394cb6a8df0c3.tar.bz2
Fixed lastError() for QTDS driver. Previously, no lastError was available on syntax errors, bad column names, etc.
Merge-request: 1987 Reviewed-by: Bill King <bill.king@nokia.com>
Diffstat (limited to 'src/sql/drivers/tds/qsql_tds.cpp')
-rw-r--r--src/sql/drivers/tds/qsql_tds.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
index 2508833..ca1502c 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/sql/drivers/tds/qsql_tds.cpp
@@ -164,13 +164,13 @@ Q_GLOBAL_STATIC(QTDSErrorHash, errs)
extern "C" {
static int CS_PUBLIC qTdsMsgHandler (DBPROCESS* dbproc,
- DBINT /*msgno*/,
+ DBINT msgno,
int msgstate,
int severity,
char* msgtext,
- char* /*srvname*/,
+ char* srvname,
char* /*procname*/,
- int /*line*/)
+ int line)
{
QTDSResultPrivate* p = errs()->value(dbproc);
@@ -181,9 +181,20 @@ static int CS_PUBLIC qTdsMsgHandler (DBPROCESS* dbproc,
}
if (severity > 0) {
- QString errMsg = QString::fromLatin1("%1 (%2)").arg(QString::fromAscii(msgtext)).arg(
- msgstate);
+ QString errMsg = QString::fromLatin1("%1 (Msg %2, Level %3, State %4, Server %5, Line %6)")
+ .arg(QString::fromAscii(msgtext))
+ .arg(msgno)
+ .arg(severity)
+ .arg(msgstate)
+ .arg(QString::fromAscii(srvname))
+ .arg(line);
p->addErrorMsg(errMsg);
+ if (severity > 10) {
+ // Severe messages are really errors in the sense of lastError
+ errMsg = p->getErrorMsgs();
+ p->lastError = qMakeError(errMsg, QSqlError::UnknownError, msgno);
+ p->clearErrorMsgs();
+ }
}
return INT_CANCEL;