Does anyone know how to pass multiple bytes to a binary (or varbinary) field using SQL and ideally in ADO (classic) and VBScript (or Visual Basic 6)?
I want to encode 10-20 (maybe more) bytes of data and store that data in an SQL db field. (This is not MS-SQLSVR, but I hope the standard SQL support format will work!)
Bytes are available as a string of bytes received through AscB / ChrB, OR, an array of bytes (in fact, variants of a byte of the type received through "cbyte") and are stored in the array.
First option: using the string format
I had some (limited) success creating an SQL insert:
x = ".>?hD-&91k[=" '<psuedo string of chars, some unprintable
Insert Into rawtest (byt) Values (CAST('" & x & "' as SQL_BINARY(12)))
But I am worried that null lines will truncate the data in the field, and other non-printable control characters will interfere with data processing. Is there any way to avoid this?
Second option: byte array
I can easily place data in an array, but I can’t figure out how to get to the SQL Insert statement. If I try to pass in 12 bytes, the insert will fail due to the fact that CAST is trying to save the data in Integer (4 bytes). If I transfer one byte, it works, for example:
x = a(0)
And it continues to work for 4 bytes, but does not work when Integer overflows. In addition, it reorders the data.
I tried using various workarounds:
Insert Into rawtest (byt) Values (CAST('12,34,45' as SQL_BINARY(12)))
Insert Into rawtest (byt) Values (CAST(&h12&h34 as SQL_BINARY(12)))
Insert Into rawtest (byt) Values (CAST(0x123456789012 as SQL_BINARY(12)))
I also tried similar combinations with:
Insert Into rawtest (byt) Values (CONVERT('" & x & "', SQL_BINARY)
But all this does not work!
, , , 20 ( 0-255, ) , , SQL .
VBScript/ADO, VB6. , "" , ascii-, Base64.
googled , SQL.
? . .