I have a SQL query( call to a stored procedure to MSSQL) that takes arbitrary length of BINARY type as argument.I am using QT's support for stored procedure. But according to this, there is no corresponding QT type for varbinary for ODBC. QT requires a type that can be converted to QVariant when passing parameters to sql queries.
For binary types of length in bytes <= 8, i used quint64, and it does not complain.
But,for arbitrary length varbinary, if i use QString, i get this error:
QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type nvarchar to binary is not allowed. Use the CONVERT function to run this query.
If i use a QByteArray, i get this error:
QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 79 (''): Data type 0x22 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."
Would be nice if anybody has any suggestions.
@a binary(2) = NULL,
@b binary(5) = NULL,
@c binary(3) = NULL,
@d binary(3) = NULL,
@e binary(8) = NULL,
@f binary(32) = NULL,
QSqlQuery query(QSqlDatabase::database(dbname));
setQueryStatement(queryString);
prepareQuery(query);
query.bindValue(":f",/* what datatype variable should i put here */);
query.exec();
Looks like QT doesn't have support for the current SQL Server data types. Can you get the procedure changed so it works with a string representation of the binary value? You could then send it a string in the form '0x23ABD234' and so on. Then you could change it to a binary value in the stored procedure.
Another option would be to create a wrapper procedure in SQL Server. Pass it a string, have it convert the value to binary and have it call the original procedure.
Alternately, is there any update to QT to support the current SQL Server data types?