Accessing Data Sample
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.
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 this sample
Install the SQL Server database that the sample uses.
In the Accessing Data Database Initialization project, open the Create Scripts folder.
Right-click the file Create Accessing Data SQL Database.sql.
Click Run on the shortcut menu.
The script creates a SQL Server database named AccessingData.
If you already have a database named AccessingData in SQL Server, this script will replace the existing database and your data will be lost.
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 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.