嗨,我試圖使用LinqToSql對象將一些數據保存到我的.sdf文件中。 我有一個表如下: -使用Linq To Sql保存到.Net中的SDF(本地數據庫文件)
PersonId int not null pk
forename nvarchar(4000)
surname nvarchar(4000)
Birthdate DateTime
IsMale bit
Biography nvarchar(4000)
我從PERSONID柱(設置爲標識,遞增)插入值到各個領域開。
我使用的
myLinqToSqlObject.Persons.InsertOnSubmit(thisPerson);
然後
thisDataContext.SubmitChanges();
的C#代碼和我得到的例外「異常已通過調用的目標引發異常。」 和一個內部例外只是「Varchar」
有誰知道我在做什麼錯?
感謝
編輯 - 顯示代碼填充thisPerson
thisPerson.Forename = thisDlg.Forename;
thisPerson.Surname = thisDlg.Surname;
thisPerson.Biography = thisDlg.Biography;
thisPerson.IsMale = thisDlg.IsMale;
thisPerson.BirthDate = thisDlg.BirthDate;
所有領域的返回值(無空值)
你可以顯示你用來填充thisPerson的代碼嗎? – BFree