Bineeshcp Viswanath

Bineeshcp Viswanath

  • NA
  • 140
  • 39.2k

How can insert null values to varbinary column

Apr 6 2019 9:43 AM
Hello All,
 
I need your help to solve a issue in my project.
 
I am using below table to store image data:-
 
 
right now, I facing a issue while inserting data to the table. insert data without image also storing as byte data. See the screenshot below:-
 
 
 
You can see in the above screenshot that some rows has long text and in the bottom, only 0x only for some rows. 
 
0x value is coming when insert null. Please find my c# code to insert data:-

imageCommand.Parameters.Add("@Image", SqlDbType.VarBinary).Value = fileUpload.PostedFile == null ? System.Data.SqlTypes.SqlBinary.Null : bytes;

Kindly help me to How I can insert null to the varbinary(max) column.

Answers (4)