I want to INSERT INTO a table in a record varbinary(max) a Byte array How can I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using a stored procedure, just create a parameter of type varbinary(max) and insert it into the table as you would any data type.
In your c# (or vb or whatever) code, add a parameter to your sql command object and set the byte array as the parameter value:
If not using a stored procedure, you can probably do the same with a parameterized sql statement, but I have never tried that, so I can’t give an example.
Edit:
You are using a parameterized query, which is not my thing, so I can’t guarantee this will work. But, here is some code that should get you going.
The binary value must be represented as a parameter (@bin_value), and the value is set by the AddWithValue statement. The parameter name does not have to match the column name.
A couple of notes: I would suggest using columns names in your insert statement rather than depending on column position, Also, I don’t know what you mean by ‘table(1)’ – is that actually the name of the table?