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.
- On the Tools menu, click Convert Main Data Source.
- 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.
- In the Data Source Wizard, click Next.
- 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.
- On the Tools menu, click Convert Main Data Source.
- 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.
- 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.
- 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.
- 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.
- Enter the location of the Web Service Description Language (WSDL) for the Web service, and then click Next.
- If requested, you must specify sample values so that InfoPath can query the Web service and collect more information about it.
- Select a parameter, and then click Set Sample Value.
- In the Set Value dialog box, type the value for the parameter.
- 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.
- In the Summary box, make sure the information matches the options you specified, and then click Finished.
- 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.
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.