Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 Accessing Data Sample
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)
Accessing Data Sample

Updated: November 2007

Note:

This sample runs only in Microsoft Office Excel 2007 and Microsoft Office Word 2007.

This sample demonstrates how to read data from a data source and display it in an Excel worksheet or Word document.

The sample contains an Excel workbook project and a Word document project. Each project document has an actions pane that displays a set of option buttons, each of which represents a different data source. When you select an option, data from that data source is displayed in the document.

Security 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.

For information about how to install the sample project on your computer, see How to: Install and Use Sample Files Found in Help.

Download sample

To run this sample

  1. Install the SQL Server database that the sample uses.

    1. In the Accessing Data Database Initialization project, open the Create Scripts folder.

    2. Right-click the file Create Accessing Data SQL Database.sql.

    3. Click Run on the shortcut menu.

      The script creates a SQL Server database named AccessingData.

      Caution:

      If you already have a database named AccessingData in SQL Server, this script will replace the existing database and your data will be lost.

  2. Press F5.

For full functionality, this sample requires the following components:

  • SQL Server installed on the local computer, with the database that is included in the sample.

  • A Microsoft Office Access 2007 database that is included in the sample.

  • The AccessingDataWebService Web service that is included in the sample.

This sample demonstrates several types of data access and display:

  • How to read data from a comma-delimited text file, an XML file, an Access database, a SQL Server data table, a SQL Server stored procedure, and a Web service.

  • How to populate a Word document and an Excel worksheet with data from a data source.

  • How to write data to ListObject controls.

  • How to write data to NamedRange controls.

  • How to write data to Bookmark controls.

The Excel sample includes a worksheet that contains a ListObject control and two NamedRange controls. When you select a data source, data is inserted into the controls on the worksheet.

The Word sample consists of a document that contains two Bookmark controls. When you select a data source, data is inserted into the controls on the document.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker