我正在尝试使用新值更新varbinary(max)列,该值也是varbinary(max) 最终结果是我得到一个新行而不是更新行。
的Sql
CREATE proc Proc_UpdateFile
@FileName varchar(50),
@OldFileName varchar(50),
@GuidNo varchar(50),
@Img varbinary(max)
as
update tbl_BazImages set ImgName=@FileName , img = @Img where GuidNo=@GuidNo and ImgName=@OldFileName
CodeBehid:
public bool UpdateFile(Byte[] bytes, string filename, string guidno,string OldFileName)
{
SqlConnection con = new SqlConnection(claims_expense);
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Proc_UpdateFile";
cmd.Parameters.AddWithValue("@GuidNo", guidno);
cmd.Parameters.AddWithValue("@FileName", filename);
cmd.Parameters.AddWithValue("@Img", bytes);
cmd.Parameters.AddWithValue("@OldFileName", OldFileName);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
eLog.WriteErrorLog(ex, "dboperation.cs", "UpdateFile");
return false;
}
finally { con.Close(); }
return true;
}