Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

Anyone know how to aolve this error....

Operand type clash: nvarchar is incompatible with image......

des:

i have an column pro_image which datatype is image....but while run it shows like this........
Posted
Updated 17-Jun-18 2:01am

The error means what it says. An image is a stream of bytes. nvarchar is a text string. So, you are trying to set an image to be an nvarchar, in SQL you did not post, so we can't tell you the exact error.
 
Share this answer
 
Comments
Member 10031043 5-Jul-13 7:30am    
Hi,

Could you help me how I can specify the datatype of the parameters
explicitly?


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
Error was

"Operand type clash: nvarchar is incompatible with image "


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


Can you help me with this ?
Christian Graus 5-Jul-13 16:58pm    
You have not posted any code, but you can create the parameter first ( specifying the type in the constructor ), then add the data to it's value.
Usually we get this error while passing DBNull.Value as the value. Can you try the following.

instead of

cmd.Parameters.AddWithValue("@imgdata", SqlDbType.Image).Value = DBNull.Value;


use the following.

SqlParameter imageParameter = new SqlParameter("@imgdata", SqlDbType.Image);
imageParameter .Value = DBNull.Value;
cmd.Parameters.Add(imageParameter );
 
Share this answer
 
Comments
CHill60 18-Jun-18 3:56am    
The question was asked and answered 5 years ago. I suggest you also test your solutions before posting ... SqlParameterCollection.AddWithValue Method (String, Object) (System.Data.SqlClient)[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900