Change or remove a data connection

A data connection is a connection between a Microsoft Office InfoPath form and an external data source, such as a database, Web service, XML file, or Microsoft Windows SharePoint Services document library or list. Data connections are used to query and submit data. If the external data sources for your form template change, you may need to modify or remove the corresponding data connections from your form template.

In this article


Before you begin

Changing or removing a form template's data connection affects the controls and data sources of any new or existing forms that are based on that form template. When you change the data connection, InfoPath creates a new data source that is based on the way that data is stored in the new external data source. If the new external data source stores data just as the old external data source did, you will not see any changes to the data source in the form template. All of the controls on the form template will be bound (bind: To connect a control to a field or group in the data source so that data entered into the control is saved. When a control is unbound, it is not connected to a field or group, and so data entered into the control will not be saved.) to the same fields in the data source. However, if the new external data source stores data in a different way from the old external data source, InfoPath creates a new data source with new fields and groups. Controls on the form template that were bound to fields in the old data source will no longer be bound to fields in the new data source. If you want to use these existing controls, you will have to bind these controls to other fields in the new data source.

You can remove only secondary data connections from a form template. You cannot remove the main data connection from a form template. When you remove a secondary data connection, InfoPath deletes the corresponding secondary data source from the form template. The controls associated with the deleted data source remain on the form template but are no longer bound to the fields and groups in that data source. If you want to use these controls, you must do one of the following:

  • Bind the unbound controls to fields or groups in the main data source or to another existing secondary data source.
  • Add a new secondary data connection to the form template, and then bind the unbound controls to fields or groups in that new secondary data source.
  • Remove the unbound controls from the form template.

 Note   Changing or removing a data connection from a form template can result in data loss for any existing forms that are based on this form template. When a user opens an existing form, InfoPath checks the published location for a newer version of the form template. If a newer version exists, InfoPath displays the form by using the newer version of the form template. If a user entered data into a control that was bound to a field in an older version of the form template, and you changed or modified the data connection, resulting in the removal of that field from the data source, the user would lose the data that was stored in the field that was removed from the data source.

Before you change or remove a data connection, be sure to consider the effects on the controls and data sources in existing forms that are based on your form template. After you change or remove a data connection, test your changes before you let your users fill out a form that is based on the modified form template.

Top of Page Top of Page

Change a data connection

  1. On the Tools menu, click Data Connections.
  1. In the Data connections for the form template list, click the data connection that you want to change.
  2. Click Modify.

The Data Connection Wizard starts to guide you through the process of changing the data connection. The next pages of the Data Connection Wizard depend upon the type of data connection that you are changing.

  1. Follow the steps in the Data Connection Wizard.

 Note   Find links to more information about using the Data Connection Wizard to connect a form to a specific external data source in the See Also section.

  1. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Top of Page Top of Page

Remove a data connection

  1. On the Tools menu, click Data Connections.
  1. In the Data connections for the form template list, click the data connection that you want to remove.
  2. Click Remove.

 Note   If the Remove button is disabled, this means that you selected the form template's main data connection. You cannot remove a form template's main data connection.

  1. In the Microsoft Office InfoPath dialog box, click Yes.
  2. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Top of Page Top of Page

 
 
Applies to:
InfoPath 2007