Qt sql datatype (QVariant) for type BINARY of arbitrary length

I have an SQL query (calling a stored procedure in MSSQL) that takes an arbitrary length of type BINARY as an argument. I use QT support for a stored procedure. But according to this , for varbinary for ODBC there is no corresponding QT type. QT requires a type that can be converted to QVariant when passing parameters to sql queries.

For binary length types in bytes <= 8, I used quint64 and it does not complain.

But for an arbitrary varbinary length, if I use QString, I get this error: QODBCResult :: exec: Cannot execute the statement: "[Microsoft] [SQL Server ODBC driver] [SQL Server] Implicit conversion from nvarchar data type to binary is not allowed. Use the CONVERT function to run this query. "

If I use QByteArray, I get this error: QODBCResult :: exec: Unable to execute statement: "[Microsoft] [SQL Server ODBC driver] [SQL Server] Invalid parameter 79 (''): Data type 0x22 is an outdated large object or LOB, but marked as an output parameter. Deprecated types are not supported as output parameters. Use the current large object types instead.

It would be nice if anyone had 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();
+4

Source: https://habr.com/ru/post/1678096/


All Articles