Inserting and Updating Data
This is the final task of the Entity Framework Quickstart. In this task, you will save changes made to Course objects bound to the DataGridView control to the database. You will also run the completed Course Manager application.
In the Toolbox, expand Common Controls, drag the Button control to the CourseViewer form designer, change the name of the control to saveChanges, and change the Text value to Update.
In the CourseViewer form designer, double-click the saveChanges control.
This creates the saveChanges_Click event handler method.
Paste the following code that saves object changes to the database.
From the Debug menu, select Start Debugging or Start Without Debugging.
This builds and starts the application.
When the form loads, select a department from the ComboBox control.
This displays the courses that belong to that department.
In the DataGridView, update course information or add a new course and then click Update.
This saves changes to the database and displays a message box to indicate that changes have been saved.