MSSQL and stored procedure
-
Hi,
How do I read nvarchar (255) output value of the stored procedure:db = QSqlDatabase::addDatabase("QODBC3"); db.setDatabaseName("Driver={SQL Server};Server=homepc\\SQLEXPRESS;Database=Test_DB;"); db.setUserName("sa"); db.setPassword("sa"); if (!db.open()) { qDebug() << "Error"; }else{ qDebug() << "OK"; } QVariant strValue(QString(255,' ')); int n = 0; QSqlQuery query; query.setForwardOnly(true); QString sqlString = "{CALL test(:Name,:Str,:Number)}"; query.prepare(sqlString); query.bindValue(":Name","Test"); query.bindValue(":Str", strValue, QSql::Out); query.bindValue(":Number", n, QSql::Out); if (!query.exec()) qDebug() << query.lastError().text(); qDebug() << query.boundValue(":Number").toInt(); qDebug() << query.boundValue(":Str").toString();
lasterror return "QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 2 (''): Data type 0x63 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object types instead."
"[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 2 (''): Data type 0x63 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object types instead. QODBC3: Unable to execute statement"If I set less value for a string size for example QVariant strValue(QString(100,' ')); stored procedure return value, itherwise value is empty.
How to correctly read the value?
RegardsQt 4.8.2 and raspberry pi [TDS][ODBC]