siddharth
siddharth

Reputation: 451

database image field passing null value

How to pass null value to database field having type of image. I am trying this but getting an error:

if (photo)
    cmd.Parameters.AddWithValue("EPhotograph",img);
else
    cmd.Parameters.AddWithValue("EPhotograph", "");
if (signn)
    cmd.Parameters.AddWithValue("ESignature",sign);
else
    cmd.Parameters.AddWithValue("ESignature",DBNull.Value);

Upvotes: 3

Views: 3760

Answers (1)

HatSoft
HatSoft

Reputation: 11201

Instead of DBNull.Value please try to put empty byte array like this new byte[0];

Reason SQL image type requires byte array as value in them.

Upvotes: 2

Related Questions