开发者

Error while trying to store image as byte array using SubSonic

Does SubSonic provide any mechanism to store image (converted in byte[] format)?

Can someone help to get rid of this error?

Database : SQL server 2005

Developing enviornment: ASP.NET (c#)

Subsonic version:2.2.1.0

Datatype in DB: image

Datatype in Subsonic generated DAL : DbType.Binary

datatype in code: byte[] ima开发者_运维技巧ge

Error at statement:

DB.Insert().Into(DamageItems.Schema, "ImageID", "Cost","Image").Values(imageID, cost,image).Execute();

Query Expression in watch window:

{INSERT INTO [dbo].[ImageItems](ImageID,Cost,Image)
 VALUES (@ins_ImageID,@ins_Cost,@ins_Image)
}

Error:

Failed to convert parameter value from a Byte[] to a String.


You may try the following approach:

DB.Insert().Into<DamageItems>()
    .Value(DamageItems.ImageIDColumn, imageID)
    .Value(DamageItems.CostColumn, cost)
    .Value(DamageItems.ImageColumn, image)
    .Execute();

Maybe the type gets properly recognized when specifying TableColumn objects (can't test right now while writing this).

If that doesn't work, I'd also check whether naming a column with a data type name (image) causes any problem.

By the way, from SQL 2005 on, image is deprecated, it is recommended to use varbinary(max) instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜