嗨,我正在尝试使用 LinqToSql 对象将一些数据保存到我的 .sdf 文件中。我有一张如下表 -
PersonId int not null pk
forename nvarchar(4000)
surname nvarchar(4000)
Birthdate DateTime
IsMale bit
Biography nvarchar(4000)
我在除 PersonId 列(设置为标识、增量)之外的所有字段中插入一个值。
我正在使用的 C# 代码
myLinqToSqlObject.Persons.InsertOnSubmit(thisPerson);
然后
thisDataContext.SubmitChanges();
我得到“异常已被调用目标抛出”的异常。和“Varchar”的内部例外
有谁知道我做错了什么?
谢谢
编辑 - 显示填充 thisPerson 的代码
thisPerson.Forename = thisDlg.Forename;
thisPerson.Surname = thisDlg.Surname;
thisPerson.Biography = thisDlg.Biography;
thisPerson.IsMale = thisDlg.IsMale;
thisPerson.BirthDate = thisDlg.BirthDate;
所有字段都返回一个值(无空值)