Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.6.3, 4.7.2
-
None
-
MSSQL 2008, Windows 7, MSVC 2008
-
f869a12c1043271b2ce8987b07a863ba3c78d6c9
Description
The following commit has introduced a regression to the ODBC driver:
http://qt.gitorious.org/qt/qt/commit/c55a99965d8c08d5f924d49db4fe4aa49df80961
Since 4.6.3 the bound value returns an empty string.
Example reproducing the problem
#include <QCoreApplication> #include <QtSql> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); QString connectionStr("Driver={SQL Server Native Client 10.0};Server=.\\SqlExpress;Database=testdb;Uid=username;Pwd=password;"); db.setDatabaseName(connectionStr); if(db.open()) { QString testStr; testStr.reserve( 100 ); QSqlQuery query; query.prepare("{CALL getTestString(?)}"); query.bindValue("testStr", testStr, QSql::Out); if( query.exec() ) { testStr = query.boundValue("testStr").toString(); if( testStr.isEmpty() ) qDebug() << "String is empty"; //always return empty string for Qt 4.7.0 else qDebug() << testStr;//works fine with version 4.6.1 } else { qDebug() << query.lastError().text(); } } else { qDebug() << "Can't connect"; } return 0; }
Creating the stored procedure
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE getTestString
@key nvarchar(50) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @key = 'TEST'
END
GO