Tuesday, April 6, 2010

Error inserting DBNull.Value into varbinary column

I have just experienced this problem: When attempting to insert DBNull.Value into a varbinary column, upon executing the insert statement the following exceptions is thrown:

”Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.”

I found the solution here: http://forums.asp.net/t/1250380.aspx

Essentially, in this case I needed to insert System.Data.SqlTypes.SqlBinary.Null instead. This resolved my problem.

No comments:

Post a Comment