Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 362
siddharth Avatar asked Dec 13 '25 06:12

siddharth


1 Answers

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.

like image 181
HatSoft Avatar answered Dec 15 '25 21:12

HatSoft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!