This project has moved and is read-only. For the latest updates, please go here.

WP7 - How to add rows to a table existing in a sterling database?

Jan 4, 2011 at 12:29 AM

Can someone please post some sample code to add new rows to an existing table in sterling?

Jan 4, 2011 at 12:38 AM
Edited Jan 4, 2011 at 6:04 PM
    public void UpdateAttendance(object param)
        AttendanceForDay objAttendanceForDay = (AttendanceForDay)param;

        // Get the Attendnace record if there is one
        Attendance objAttendanceRecord = 

        if (objAttendanceRecord == null) // New Record
            // If Attendance Record was not found create a new record
            Attendance NewAttendanceRecord = new Attendance();
            NewAttendanceRecord.AttendanceKey = objAttendanceForDay.AttendanceKey;
            NewAttendanceRecord.AttendanceDate = AttendanceDate;
            NewAttendanceRecord.EnrollmentId = objAttendanceForDay.EnrollmentId;
            NewAttendanceRecord.AttendanceStatus = objAttendanceForDay.AttendanceStatus;
        else // Update Record
            // Set Attendanace status and save the record
            objAttendanceRecord.AttendanceStatus = objAttendanceForDay.AttendanceStatus;

Jan 4, 2011 at 3:59 AM


I am able to add new rows in the DB when the App is activated (in WP7 Emulator) for the 1st time. From the second time onwards, when I add a new row it overwrites the 1st row in addition to adding a new row to the table (Type). Am I doing everying right in the App.xaml.cs?  do I need to check for the presence of the DB before calling RegisterDatabase<ClassType>?

 _engine = new SterlingEngine();
 _logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
 _database = _engine.SterlingDatabase.RegisterDatabase<TClassype>();
Jan 4, 2011 at 4:27 PM

Please take a look here and make sure you are following the setup in the App.xaml.cs to handle tombstoning: