Show All

# About changing a form's main data source

At times, you may need to modify a form to use a different XML Schema, database server, or Web service before or after deployment. You do not have to modify the form definition file (.xsf) to accomplish this task, however, because with Microsoft Office InfoPath 2003 Service Pack 1 or later, you can change the main data source of your form through the InfoPath designer.

The steps you need to take to do this differ, depending on whether your form's main data source is an XML Schema, an XML document, or a data connection.

Change the main data source of a form based on an XML Schema or XML document.

Follow these steps to change the main data source of a form that is based on an XML document or Schema:

1. On the Tools menu, click Convert Main Data Source.
2. In the Data Source Wizard, click Browse, and then, in the Open dialog box, browse to and select the XML document you want to base the form on. Click Open.
3. In the Data Source Wizard, click Next.
4. Click Yes under Do you want to add another XML Schema or XML document to the main data source? if you want to add another XML Schema or XML document to your form's main data source. Click Finish if you do not want to add more XML Schemas or XML documents to the main data source.

Once you specify the new data source, all dependent data will be mapped to the new data source. If the dependent data cannot be mapped, controls will appear unbound in the view.

Note You cannot change your form's main data source to a data connection if it is based on an XML Schema or XML document.

Change the main data source of a form based on a data connection.

Follow these steps to change the main data source of a form that is based on a data connection.

1. On the Tools menu, click Convert Main Data Source.
2. Click Database under Select the type of data connection you want to use for your form if you want to change the main data source of your form to a Microsoft Office Access or Microsoft SQL Server database. Select Web service if you want to connect your form to a Web service. Click Next.
3. Follow the steps under one of the following headings, depending on whether you selected Database or Web service in step 2.

   Change the main data source of a form to a database.

   1. On the second page of the Data Source Wizard, click Select Database, and then, in the Select Data Source dialog box, browse to and select the SQL Server or Access database you want to base the form on, and click Open.

      Note If there is more than one table in your database, in the Select Table dialog box, click the table you want to have as the primary parent table for your form, and then click OK.

   2. If you want to add more than one table, do the following:
      - Click Add Table.
      - In the Add Table or Query dialog box, click the table you want to add, and then click Next.
      - In the Edit Relationship dialog box, make sure the connecting fields are correct. To add a set of connecting fields, click Add Relationship, select the two fields that are equal when a record in one table is associated with a record in another table, and then click OK.
      - In the Edit Relationship dialog box, click Finish.
      - In the Data Source Wizard, click Next.
      - In the Summary box, make sure that the information matches the options you specified, and then click Finished.

   Change the main data source of a form to a Web service.

   1. Enter the location of the Web Service Description Language (WSDL) for the Web service, and then click Next.
   2. If requested, you must specify sample values so that InfoPath can query the Web service and collect more information about it.

      How?

      - Select a parameter, and then click Set Sample Value.
      - In the Set Value dialog box, type the value for the parameter.
   3. On the next page of the wizard, specify the Web service operation that you want to provide the data for your form, and then click Next.
   4. In the Summary box, make sure the information matches the options you specified, and then click Finished.

Once you specify the new data source, all dependent data will be mapped to the new data source. If the dependent data cannot be mapped, controls will appear unbound in the view.

Note You cannot change your form's main data source to an XML Schema or XML document if it is based on a data connection.

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp