Linq to sql 字符串或二进制数据将被截断。声明已被终止
在这些更新之前,我有一个insert语句: 在db.sumbitchanges上显示错误Linq to sql 字符串或二进制数据将被截断。声明已被终止,linq-to-sql,Linq To Sql,在这些更新之前,我有一个insert语句: 在db.sumbitchanges上显示错误 Topic top = (from t in db.Topics where t.id == id select t).SingleOrDefault(); top.lastpost = username + maxdate; Category ca = (from c in db.Categories wh
Topic top = (from t in db.Topics
where t.id == id
select t).SingleOrDefault();
top.lastpost = username + maxdate;
Category ca = (from c in db.Categories
where c.categoryid == cat
select c).SingleOrDefault();
ca.totaltopics = ca.totaltopics + 1;
ca.posts = ca.posts + 1;
ca.lastpost = username + maxdate;
db.SubmitChanges();
字符串比DB列的大小长,因此结果数据不适合内部。字符串比DB列的大小长,因此结果数据不适合内部。听起来像是
top.lastpost
或ca.lastpost
(或两者兼而有之)数据库上没有足够的空间容纳username
+maxdate
检查数据库字段允许的字符数,或者更改字段以允许更多字符,或者缩短输出长度-可能仅存储
username+maxdate.ToString(“yyyy-MM-dd”)
或username+maxdate.ToString(“yyyy-MM-dd HH:MM:ss”)
?这听起来像是top.lastpost
或ca.lastpost
(或两者)在数据库上没有足够的空间来容纳用户名+maxdate
检查数据库字段允许的字符数,或者更改字段以允许更多字符,或者缩短输出长度-可能仅存储username+maxdate.ToString(“yyyy-MM-dd”)
或username+maxdate.ToString(“yyyy-MM-dd HH:MM:ss”)
?我假设主题都是。lastpost
和类别。lastpost
是字符串,而用户名+maxdate
连接了两个字符串。结果可能比相应表中的lastpost
列中的值大一些。我假设主题。lastpost
和类别。lastpost
是字符串
s,并且用户名+最大日期
连接两个字符串。结果可能会比相应表中lastpost
列的值稍大一些