Problems with passing Binary as a table-valued parameter

Kwan 0 Reputation points
2024-11-05T02:41:32.4433333+00:00

I'm using table-valued parameters to pass binary values.

I used SQLBindParameter and passed the values as SQL_C_BINARY, SQL_BINARY, BinarySize, etc. as the arguments, but when I run SQLExecute, I get an error or the result is different from what I expected.

There are two typical cases of error messages.

First

In Binary(40), if the 40-byte value contains a zero in the middle, the subsequent values are terminated.

Secondly

Binary(40) is passed with 40 bytes full, the error message “String or Binary will be truncated” is displayed.

The other datatypes are working fine, CHAR and VARCHAR are also working fine.

Based on this result, I wonder if the value is recognized as a string during the passing process, even though I specified Binary as SQLBindParameter.

Please help...

Translated with www.DeepL.com/Translator (free version)

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,961 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,758 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.