I'm trying to update a varbinary
in my MSSQL with a binary array of an image.
I tried using this query, which doesn't seem to work:
string sql = "UPDATE table SET bdata='" + imagedata + "' WHERE ID=1";
This is just an example of a query I used. Why doesn't it work? And I prefer not using SqlCommand
.
bdata is of type varbinary(max)
and imagedata is a byte
array.
What am I doing wrong that it's not working? An exception tells me I need to use CONVERT
or something like that..
This is the given exception when trying to run it:
Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.