I am working on a VBS project in which I need to retrieve a "varbinary(max)" from a database as a string.
I use an ADODB.Recordset that I parse using a While loop (while it’s not EOF)
Consider the following code :
Set ArticlesEBP = CreateObject("ADODB.Recordset") ArticlesEBP.Open "SELECT * FROM MyTable", EBP_ConnServeur While Not ArticlesEBP.EOF WScript.Echo ArticlesEBP("bImage") ArticlesEBP.MoveNext Wend
In my database, there is only one row with a valid varbinary(max) field, this is how it looks :
Here is a link containing the full varbinary data : https://pastebin.com/cBt2bdmf
I know it is valid, because I used it for my tests (converted it to base64 then to a jpg…), it’s just now that I try to actually retrieve the data from the database that I’m getting issues.
When I run the VBS code above, I get weird results : the console just prints out "??".
If I replace the "WScript.Echo" with a "MsgBox" I can see two chinese characters, so I don’t get it.
Can anyone indicate me how I should do this ?
Source: Windows Questions