I have a SQL Server database, and I want to store in image type column some string.
I'm trying to do the following :
SqlParameter myparam = new SqlParameter("@myparam", "VeryLongString");
myparam.SqlDbType = SqlDbType.Image;
when I add it to the command and then execute it, I get the following error :
Failed to convert parameter value from a String to a Byte[]
What seems to be the problem ?
thanks in advance
An Image field in SQL Server stores a byte array (the bytes that make up the image), not a string.
If you're truly trying to pass in a very long string, you should use SqlDbType.Text
.