3

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);
1
  • 2
    What is the error you got? Please post it. Or may be the database column ESignature is not a Nullable column. Ensure it is not NOT NULL Commented Jul 10, 2012 at 7:40

1 Answer 1

2

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.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.