Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with writing out binary data in VB

Author  Topic 

DaveBF
Yak Posting Veteran

89 Posts

Posted - 2014-10-08 : 09:07:29
I'm writing a function which reads a file and writes the data to out a column defined as varbinary(max).
I have this code to read the data.

Dim buffer As Byte() = New Byte(CInt(len) - 1) {}
fu.FileContent.Read(buffer, 0, buffer.Length)

That works fine.
Now I want to construct a SQL command.


dim cmd as String
cmd = "Update mytable set mycolumn = '"+buffer+"' where key=2"


I don't how to do the above. I tried buffer.tostring() but that wasn't right. Do I need a loop?
Thanks.

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-10-08 : 11:51:20
[code]"Update mytable set mycolumn = cast('"+buffer+"', as varbinary(max)) where key=2"[/code]Caveat emptor: Untested...



No amount of belief makes something a fact. -James Randi
Go to Top of Page
   

- Advertisement -