0

I have the following code: I am getting the following error message:

Operand type clash: nvarchar is incompatible with image 

when the code tries to do: cmd.ExecuteNonQuery(); Note that I get this error only when _ImageB is null. ImageB is stored as a Image Data type in the SQL Server table.

if (_ImageB == null)
{
    cmd.Parameters.AddWithValue("@ImageB", DBNull.Value);
}
else
{
    cmd.Parameters.AddWithValue("@ImageB", _ImageB);
}
Christos
  • 53,228
  • 8
  • 76
  • 108
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
  • 4
    possible duplicate of [Operand type clash: nvarchar is incompatible with image](http://stackoverflow.com/questions/2420708/operand-type-clash-nvarchar-is-incompatible-with-image) – rlb.usa Sep 09 '15 at 19:14

1 Answers1

1

Try this!

cmd.Parameters.Add("@ImageB", SqlDbType.Image).Value = _ImageB == null ? DBNull.Value : _ImageB;