Export (0) Print
Expand All

Data Caching Sample

NoteNote:

This sample runs only in Microsoft Office Word 2007.

This sample demonstrates how to retrieve data from an XML file, store the data in a Word document’s data cache, and then work with that data from within the document itself or from a Windows Forms application.

The sample is a customer satisfaction survey that is designed to be used offline. Survey information is stored in an XML file; you can load the data into the document's data cache to review or work with the data.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run the sample

  1. Press F5.

    An empty document is displayed. There is no data in the cache.

  2. Click Retrieve Surveys.

    The data is loaded from the XML file into the data cache and the first survey is displayed.

  3. You can perform any of the following actions:

    • Edit the survey data.

    • Complete a survey.

    • Navigate through the survey data by using the navigation bar in the actions pane.

    • Filter the survey data to see all completed surveys, all incomplete surveys, or all surveys regardless of completion by selecting the appropriate option button in the actions pane.

    • Submit survey data back to the data source by using the Submit Surveys button in the actions pane.

  4. Save and close the document.

    The data is saved in the document's data cache.

  5. In Visual Studio, right-click the Windows Forms project, point to Debug, and then click Start new instance.

    The Customer Satisfaction Survey Data application opens.

  6. On the File menu, click Open.

  7. Navigate to the document you saved and then click Open.

    The DataGrid is populated with the data from the document's data cache.

  8. Review the data and make any changes you want.

  9. On the File menu, click Save to save changes to the data cache.

The sample demonstrates the following tasks:

  • Retrieve, use, and update data from an XML file.

  • Store data in a data cache.

  • Read data from and write changes to a data cache.

  • Display data in a Word document by using bookmark controls.

  • Use an actions pane within a Word document.

  • Use Windows Forms controls on a Word document.

  • Access and use a document’s cached data from a Windows Forms application.

Community Additions

ADD
Show:
© 2014 Microsoft