On singleton SELECT statements and cursor fetches, Microsoft® SQL Server™ binary, varbinary, and image columns are mapped to C host variables declared as character arrays without any data conversion. The host variable is treated as a byte array. To retrieve the hexadecimal character representation of a binary, varbinary, or image column, use the Transact-SQL CONVERT function on the column.
When input, a C character array data type can be mapped to a SQL Server binary, varbinary, or image column by using dynamic SQL statements. To do this, use two question marks (??) as parameter markers. The data format on input is the raw binary data (not its hexadecimal character representation.) If you include at least one space between the parameter marker and its indicator, you can use indicator variables. You cannot use static SQL statements to map binary data on input parameters.
You can use static SQL statements to map binary data on input parameters. However, you will need to modify the generated .c code manually to specify the length of the variable. For example, if you declare the void *pChar variable, the precompiler will generate a sqlasetv to set the parameter length to unknown by putting -1 as the parameter length. The third parameter of -1 indicates that this is a pointer. You may have to modify this length to indicate proper size of data contained in pChar. The .c source can then be compiled and linked as usual.