SQL/ODBC: properly set SQL_ATTR_CURSOR_SCROLLABLE
Setting a query in forward-only or scrollable mode was done with SQL_ATTR_CURSOR_TYPE in ODBCv2. Nearly all ODBCv3 drivers also honor this value but some don't and need the ODBC v3 conformant SQL_ATTR_CURSOR_SCROLLABLE attribute instead. Fix it by setting both attributes. Fixes: QTBUG-126118 Pick-to: 6.7 6.5 Change-Id: I6d974b7b3e94113b0a87f1cc7f8cff0deb53642b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 730de6fbb09f082f32dfa355502551a0d6b8ae34) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f7f5795ec7
commit
03e6f3859a
@ -964,22 +964,22 @@ bool QODBCResult::reset (const QString& query)
|
||||
|
||||
d->updateStmtHandleState();
|
||||
|
||||
if (isForwardOnly()) {
|
||||
r = SQLSetStmtAttr(d->hStmt,
|
||||
SQL_ATTR_CURSOR_TYPE,
|
||||
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
|
||||
SQL_IS_UINTEGER);
|
||||
} else {
|
||||
r = SQLSetStmtAttr(d->hStmt,
|
||||
SQL_ATTR_CURSOR_TYPE,
|
||||
(SQLPOINTER)SQL_CURSOR_STATIC,
|
||||
SQL_IS_UINTEGER);
|
||||
}
|
||||
// ODBCv3 version of setting a forward-only query
|
||||
uint64_t sqlStmtVal = isForwardOnly() ? SQL_NONSCROLLABLE : SQL_SCROLLABLE;
|
||||
r = SQLSetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, SQLPOINTER(sqlStmtVal), SQL_IS_UINTEGER);
|
||||
if (!SQL_SUCCEEDED(r)) {
|
||||
setLastError(qMakeError(QCoreApplication::translate("QODBCResult",
|
||||
"QODBCResult::reset: Unable to set 'SQL_CURSOR_STATIC' as statement attribute. "
|
||||
"Please check your ODBC driver configuration"), QSqlError::StatementError, d));
|
||||
return false;
|
||||
// ODBCv2 version of setting a forward-only query
|
||||
sqlStmtVal = isForwardOnly() ? SQL_CURSOR_FORWARD_ONLY : SQL_CURSOR_STATIC;
|
||||
r = SQLSetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_TYPE, SQLPOINTER(sqlStmtVal), SQL_IS_UINTEGER);
|
||||
if (!SQL_SUCCEEDED(r)) {
|
||||
setLastError(qMakeError(
|
||||
QCoreApplication::translate("QODBCResult",
|
||||
"QODBCResult::reset: Unable to set 'SQL_ATTR_CURSOR_TYPE' "
|
||||
"as statement attribute. "
|
||||
"Please check your ODBC driver configuration"),
|
||||
QSqlError::StatementError, d));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user