How to: Persist Data Changes to the Database (Devices)

Use these procedures to persist changes that were made to data in device projects.

The following steps, written in C# and relying on the Customers table of the Northwind database, assume that you have a dataset (not any other kind of data source) in the Data Sources window. For more information, see How to: Add a Database to a Device Project.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To persist data changes to the database

  1. Drag a table from the Data Sources window onto a Windows Form.

  2. Drag a button onto the form.

  3. Change the Text property of the button to Save.

  4. Double-click the button on the form to open the code editor at the button click event handler.

  5. Type the following code:

    this.customersBindingSource.EndEdit();
    this.customersTableAdapter.Update(this.northwindDataSet.
       Customers);
    

See Also

Concepts

Using SQL Server Compact 3.5 Databases (Devices)