views:

721

answers:

2

I tried to set the parameter value to system.dbnull.value but got some errors. thanks.

+1  A: 

What is happening is that SQLServer is reading the NULL type as nvarchar, which cannot be used to update an Image column.

Try specifying the Parameter Type as SqlDbType.Image

SqlParameter myParam = new SqlParameter("@NameOfParameter",SqlDbType.Image);
Matthew Jones
A: 

An alternative is to not use a parameter when you're setting it to null. Instead, you can hardcode '=null' in the SQL command and skip parameters completely.

Andrew
This works, but he might be coding this into his datalayer and wants to be able t o set the correct parameter value.
ck