Database row with bytes

I have a database which contains binary data as system.bytes. I can convert the content with a powershell into a binary file but I didn’t get the value of the content as a readable variable:

But to put the content to a file or pass it as parameter it only says: “System.Byte

Here it says that I’m not allow to write
So I have added “tostring”:
but the out put stays with “System.Byte”. All tries with convert oder ctype were not successful
This will give a the output “System.Byte” but not the content.
Please help to get at least the byte array write as text to a file.

Why don’t you use File.WriteAllBytes() to save it to a file? You can call the method using Invoke Method or Invoke Code.


Probably, It’s Zlib compressed data. What is original data type?

First, decompress the byte array using ZlibStream class. Then handle the result by proper way depending on original format.


Thanks for your support. But even if it’s zipped, it’s still a byte-array variable, right? I don’t have any issues to get the content out of it, but I need to get the content to pass it into a file or as a parameter for my PS1, which will convert each byte into a char (which works when I copy the content manually by my SQL console).

error BC30512: “Option Strict On” does not allow convert (translated) “Object” in “Byte()”.

Hi @TP2B ,

Can you check below codes in immediate window,



Let us know if you still have any issue?

1 Like

Have you tested to cast it to byte array first?

File.WriteAllBytes(testFile, DirectCast(CurrentRow.Item(2), Byte()))

The following errors were encountered while processing the workflow tree:
‘VisualBasicValue’: Compiler error(s) encountered processing expression “File.WriteAllBytes(“c:\buffer\infu.txt”, DirectCast(CurrentRow.Item(2), Byte()))”.(2) : error BC30491: Expression does not produce a value.


Have you run the code? The function doesn’t return any result so you can’t use it in the Immediate pane.

like this?

What type of variable should I use?

1 Like

CurrentRow should be of type DataRow.

Thanks for support. But clear how to manage:
File.WriteAllBytes(“C:\buffer\inu1.txt”, DirectCast(CurrentRow.Item(2), Byte()))
Argument: ?


same problem?

No need for other arguments. Just change the type of CurrentRow from Object to DataRow and then you should be able to run the code as is.

The type should be DataRow, not String.

that looks much better now!
but it’s a matter of encoding I think

any idea how to get it as this:

It’s a binary file so it won’t look good when you open it as a text file. Do you know what kind of data it is? E.g. if it’s a pdf, you could test to change “.txt” to “.pdf”.

If you just want the numbers, you can use String.Join():

String.Join(", ", DirectCast(CurrentRow.Item(2), Byte()))

Thank you very much, I will still have to work on. When I copied the bytes from SQL I was able to convert and got a rtf file. But a RTF looks very different as to the screen I shared before.