Operand type clash: nvarchar is incompatible with image

  • Thread starter Thread starter Diego
  • Start date Start date
D

Diego

I'm using a msSqlServer 2000 stored procedure to create a new record with
this syntax: :

cmd.Parameters.Add("@photo", DBNull.Value);
cmd.ExecuteNonQuery();

but the result is a:
Operand type clash: nvarchar is incompatible with image
Photo is not the only parameter but is the only image one, I am not passing
a nvarchar but a null value, am I missing something?
Diego.
 
If you don't seta data type on the parameter, it will default to varchar.
You need to explicitly set it to image.
 
Hi Diego,

Always specify datatype of the parameters explicitly. Otherwise it could
lead to the fact that your are passing invalid datatypes. By-default your
parameter will be declared as varchar and in your case it will not work.
 
Hi,

Could you help me how I can specify the datatype of the parameters
explicitly?
I have the same problem as Diego....

I have a column named "Picture" and as Column Type "Image", but when I would
like to update or insert an image into my DB I receive the same error as
Diego...

I'm using ASP.NET2.0 and using DetailsView with an EditTemplate.

Can you help me with this ?

Thanks,
Bart
 
You need to specify the data type of the SqlParameter using the SqlType
property. If you don't specify the data type of the parameter, it defaults
to 'nvarchar' which is most likely what you are seeing.

Thanx
Lale Divringi

DISCLAIMER: This posting is provided "AS IS" with no warranties, and confers
no rights.
 
Back
Top