我将Rowversion数据发送到我的视图,以测试更新/删除记录到SQL Server的并发问题。记录中的Rowversion数据是Byte [],必须将其转换为Base64字符串才能序列化。这是由我的ViewModel中的getter完成的。返回的Base64数据正由setter转换回Byte []。 (我相信这是处理SQL Server rowversion数据时的标准做法。)
我的ViewModel是......
public byte[] RowVersionId { get; set; }
public string RowVersionIdBase64
{
get
{
if (this.RowVersionId != null)
{
return Convert.ToBase64String(this.RowVersionId);
}
return string.Empty;
}
set
{
if (string.IsNullOrEmpty(value))
{
this.RowVersionId = null;
}
else
{
this.RowVersionId = Convert.FromBase64String(value);
}
}
}
帖子导致错误"输入不是有效的Base-64字符串,因为它包含非基本64个字符,两个以上的填充字符或填充字符中的非法字符。"
Firebug显示的帖子参数是......(这里显示的相关数据 - 抱歉,但是有些人会在某种程度上破坏布局)
...
RowVersionIdBase64
AAAAAAAAF3E =
RowVersionId []
0
RowVersionId []
0
RowVersionId []
0
RowVersionId []
0
RowVersionId []
0
RowVersionId []
0
RowVersionId []
23
RowVersionId []
113
...
帖子来源是......(此处显示的完整帖子数据)
属性ID = 1&安培; RateFromDate =星期六+月+ 15 + 2017 + 00%3A00%3A00 + GMT%2B1000 +(AUS +东+ +标准时间)及RateToDate =星期六+月+ 15 + 2017 + 00%3A00%3A00 + GMT%2B1000 +(AUS +东+ +标准时间)及RateName = FFF&安培; RateComment =安培; MinimumStay = 1&安培; WeekRate = 0&安培; WeekendRate =安培; WeekEndNightRate = 150安培; MidweekNightRate = 100安培; MonthRate = 0&安培; FullPeriodRate = 0&安培;取消 =假安培; dateCreated会=星期四+月+ 14 + 2016 + 07%3A57%3A16 + GMT%2B1000 +(AUS +东+ +标准时间)及DateCancelled =&安培; RowVersionId%5B%5D = 0&安培; RowVersionId%5B%5D = 0&安培; RowVersionId%5B%5D = 0&安培; RowVersionId%5B%5D = 0&安培; RowVersionId%5B %5D = 0&安培; RowVersionId%5B%5D = 0&安培; RowVersionId%5B%5D = 23&安培; RowVersionId%5B%5D = 113&安培; RowVersionIdBase64 = AAAAAAAAF3E%3D和ID = 7
它有什么问题,如何解决?
谢谢。
答案 0 :(得分:0)
此错误的一个可能原因是2个html输入具有相同的名称。
答案 1 :(得分:0)
--rowvers is define as a timestamp in the table
SELECT TOP (100)
rowvers ,
( SELECT CAST(rowvers as varbinary(max)) FOR XML PATH(''), BINARY BASE64 )
FROM
[hpodb].[dbo].[mytable]
再投一次不破坏 SSMS 导出
SELECT TOP (100)
rowvers ,
cast(( SELECT CAST(rowvers as varbinary(max)) FOR XML PATH(''), BINARY BASE64 ) as varchar)
FROM [hpodb].[dbo].[mytable]