将文件从asp.net上传到SQL Server 2008,上传到SQL Server后我看到附件内容为:0x89
我的存储过程接受:@AttachContent varbinary,
以下是我上传的代码。
public bool AttachmentInsert(int mimeTypeId, string attachFileName,
byte[] attachContent)
{
using (DataContextDataContext dc = conn.GetContext())
{
int attachId = (int)dc.spAttachment_Insert(mimeTypeId, attachFileName,
attachContent).ReturnValue;
if (attachId != 0)
{
return true;
}
return false;
}
}
[Function(Name="dbo.spAttachment_Insert")]
public ISingleResult<spAttachment_InsertResult> spAttachment_Insert(Name="AttachContent", DbType="VarBinary(1)")] System.Data.Linq.Binary attachContent,
{
IExecuteResult result =
this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())),
mimeTypeID, attachFileName, attachContent);
return ((ISingleResult<spAttachment_InsertResult>)(result.ReturnValue));
}
任何帮助如何纠正。
答案 0 :(得分:3)
DbType="VarBinary(1)"
您将内容截断为1个字节。请改用VarBinary(max)
。