Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

Can anyone solve this.
Record Not Inserted Successfully Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
how to solve this error?
Posted
Updated 9-Mar-12 20:44pm
v2
Comments
Uday P.Singh 10-Mar-12 1:00am    
show us your code!

1 solution

Without seeing your code, it is difficult to be sure, but the error message is quite explicit.

You have a field in your database that you have declared as VARBINARY(MAX) which you are trying to insert a value to.
Either, you are trying to do this by concatenating strings to form an SQL statement:
C#
string sql = "INSERT INTO myTable (myColumn) VALUES ('" + myDataForColumn + "')";
Which is a very, very bad idea as it leaves your database open to SQL Injection attack, or you are doing it via a parametrized query but setting the wrong parameter type, or passing a string to SqlCommand.Parameters.AddWithValue instead of an array of bytes.
 
Share this answer
 

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