I'm getting the following exception when I attempt to insert some sample data into a SQL Server CE 3.5 database inside a WP7 application:
Error: SqlCeException "The column cannot contain null values.
[ Column name = Name,Table name = Exam ]
The name
is also the primary key. I think I have declared everything properly in the 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();
}
Where have I gone wrong?
I solved the problem by deleting the index(es) of The Table. Not sure why it worked, but it certainly did, in case anyone else comes across this issue.