当我尝试将一些示例数据插入 WP7 应用程序内的 SQL Server CE 3.5 数据库时,出现以下异常:
错误:SqlCeException“列不能包含空值。
[列名=名称,表名=考试]
name
也是主键。我想我已经在DataContext
.
private void InsertData()
{
mangoDb = new ExamDataContext();
// create a new exam instance
Exam exam = new Exam();
exam.Name = "History";
exam.Description ="History Exam";
// add the new exam to the context
mangoDb.Exams.InsertOnSubmit(exam);
// save changes to the database
mangoDb.SubmitChanges();
}
我哪里出错了?