About data connections

A data connection establishes a dynamic link between a form and an external data source, such as a Web service or database, which allows users to view and work with data from that data source (data source: The collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the data source.). In particular, a data connection can be used to populate the choices in a list box; receive data from a database, Web service, Microsoft Windows SharePoint Services site, or XML (Extensible Markup Language (XML): A condensed form of Standard Generalized Markup Language (SGML) that enables developers to create customized tags that offer flexibility in organizing and presenting information.) document; submit data to a database, Web service, or Microsoft Windows SharePoint Services form library (form library: A folder in which a collection of forms based on the same template is stored and shared. Each form in a form library is associated with user-defined information that is displayed in the content listing for that library.); or submit a form as an attachment in an e-mail message.

There are two types of data connections: those that receive data from an external data source and those that submit data externally. These two types of data connections function slightly differently based on whether they are primary data connections, which are established when the form is first designed, or secondary data connections, which are added after the form is designed.

 Note   When you design a form based on a database, the resulting primary data connection can both submit and receive data.

Primary and secondary data connections

You can create a primary data connection by designing a form that is based on a database or Web service. The main data source for the form is then defined by the structure and properties of the database or Web service. If you add a data connection that receives data to an existing form, however, the data connection results in a secondary data source, whose fields and groups contain the data that's received.

A secondary data source can be used in the same ways as a primary data source, with the following exceptions:

Because any data source that is associated with a data connection must match the structure of the external data source, the following limitations apply to both primary and secondary data sources:

  • The data source cannot be created automatically by inserting controls into the form.
  • The structure and properties of existing fields or groups in the data source cannot be modified. In primary data connections, however, you can add fields or groups to the root group in the data source.

Data connections that receive data (secondary data sources)

When you add a data connection to a form that receives data, Microsoft Office InfoPath 2003 creates a secondary data source for the form that matches the structure of the external data source. This external data source can include databases, Web services, Windows SharePoint Services form libraries and lists, and XML documents.

You can work with the form's secondary data source in the same way that you work with the form's primary data source. For example, you can create controls based on the secondary data source, and then apply conditional formatting (conditional formatting: The process of changing the appearance of a control, including its visibility and read-write state, based on values entered into the form.) to the controls. Depending on the options you specify when creating the data connection, the data from the data connection can be retrieved either automatically when the form is opened or when the user requests it.

Data connections that submit data

Unlike primary data connections or secondary data connections that receive data, data connections that submit data do not affect the form's data sources. Instead, they establish a connection between the form's existing data sources and an external data source, which enables the form's data to be submitted to a database, Web service, or a Windows SharePoint Services form library. You can also create a data connection that will submit your form as an attachment in an e-mail message.

In most cases, you will submit the entire form when using a data connection that submits data. In the case of Web services, however, you can choose to submit specific parts of the form. You can also define how you want the data to be submitted to the Web service — for example, whether you want to include the entire field or just the contents of the field, or whether you want to send the data as a string to preserve white spaces.

 Note   The information in this topic may not apply if you are working with a form designed using Microsoft Office InfoPath 2003 without the service pack installed.

Applies to:
InfoPath 2003