我遇到错误 不允许使用convert函数将数据类型从varchar隐式转换为varbinary
我已在ms sql服务器中使用varbinary(max)数据类型存储图像并将图像转换为byte []并尝试保存图像。
public bool InsertProd(PRODUCT_CAT crse)
{
StringBuilder query = new StringBuilder();
bool success;
query.Append("INSERT INTO PRODUCT_CATEGORY (PROD_CATE_ID,PROD_IMAGE) VALUES"('" + crse.Id + "',','" +crse.Image+ "')");
success = dbObj.ExecuteQuery(query.ToString());
return success;
}
public class PRODUCT_CAT
{
public int Id { get; set; }
public byte[] Image { get; set; }
public PRODUCT_CAT(int id,byte[] image)
{
Id = id;
Image = image;
}
}