The problem is that what you are trying to insert into the database IMAGE column is a
string
- which is NVARCHAR - and the column requires VARBINARY data, or
byte
array.
The difference is that a
string
is made of
char
values, which are 16 bit values which do not necessarily allow for all the possible values. On the other hand
byte
data is 8 bit and allows the full range of values in those eight bits: 0 to 255 inclusive.
What you need to do is convert your image to byte data instead of string, and I can't tell you exactly how to do that as I have no idea what your BarcodeImage method returns.
This may help, however:
Why do I get a "Parameter is not valid." exception when I read an image from my database?[
^] - it shows how to convert an Image to an array of bytes and pass it to a DB.