Data for Silverlight
Add the Database Access Infrastructure
The Sample Application > Implement the Server Side > Add the Database Access Infrastructure

Before implementing the Web services, add the database itself to the project. This step is optional. We use a connection string to specify where the database is located, so we could use any existing copy of the MDB file already in the system. We will create a local copy here to facilitate deployment and to avoid making changes to the original database.

To add the database to the project, complete the following steps:

  1. Right-click the App_Data node in the MasterDetailWeb project and select Add | Existing Item.
  2. In the dialog box, locate the NWIND.MDB file and add it to the project.
  3. In the Properties window, set the Build Action property to None.

The image below shows the Solution Explorer window after this step is completed:

NWIND.mdb in the AppData folder.

In addition to the database file, we need a mechanism to transfer data from and to the database. In this sample, we accomplish this using a utility class called SmartDataSet. SmartDataSet extends the regular ADO.NET DataSet class and adds the following:

The SmartDataSet is convenient but not necessary. It knows how to create and configure DataAdapter objects used to load and save data, but you could also write standard ADO.NET code to accomplish the same thing. Because it only uses standard ADO.NET techniques, we do not list it here.

To add the SmartDataSet.cs file to the project, complete the following:

  1. Right-click the MasterDetailWeb node in the Solution Explorer, select Add | Existing Item.
  2. In the Add Existing Item dialog box, locate the SmartDataSet.cs file in the C1.Silverlight distribution package and click Add to add it to the project.
See Also