Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

In this article

Overview

If you are designing several form templates that use similar data connections, consider using a data connection file instead of creating a data connection to an external data source for each form template. This way, you need to update only one data connection file when the data connection information changes for a set of related form templates. For example, when you move your form templates from a test network to a production network, you need to update the data connection settings only once in the connection library instead of updating the data connection in each form template. When a form based on a form template that uses a data connection file uses the data connection, the data connection is automatically updated with the new settings.

A data connection file is an XML file with an .xml or .udcx file extension that contains connection information for a single external data source. This file is stored in a data connection library on a server running Microsoft Office SharePoint Server 2007. A data connection file is created by a developer or by converting a data connection in an existing form template into a data connection file by clicking the Convert button in the Data Connections dialog box (Tools menu).

Advantages of using data connection files include:

  • Multiple forms can use the same data connection file, so there is no need to create the same data connection from scratch for each form template.

  • If the location or connection settings for an external data source change, you need to update only the data connection file, not each form template.

  • The data connection file can contain alternative authentication information that can be used by the server when a user fills out a form by using a Web browser.

  • Forms based on a browser-compatible form template that are filled out in a browser can connect to servers in another domain only with data connections that use data connection files.

Note: Microsoft Office InfoPath uses data connection files that follow the Universal Data Connection version 2.0 file format. This version is a superset of the version 1.0 file format used by Microsoft Office FrontPage and Microsoft Office Excel. InfoPath cannot use data connection files in the version 1.0 file format.

When you add a data connection to a form template by using the settings in a data connection library, you create a secondary data connection in that form template. This data connection is different from the main data connection that is created when you design a form template based on a database, a Web service, or settings in a data connection library. You would add a secondary data connection only if you cannot get or send data through the main data connection.

Top of Page

Before you begin

In order to add a data connection to your form template by using the settings that are stored in a data connection library, you need the following information from the site administrator:

  • The location of the server that is running Microsoft Office SharePoint Server 2007, which contains the site that includes the data connection library

  • The name of the data connection file in the data connection library that you want to use

  • Whether the data connection file contains settings for a query data connection or a submit data connection

  • Whether you can configure the form template to safely store the query results in the form for offline use if the settings are for a query data connection

Top of Page

Add a query data connection

In order to add a data connection to your form template by using settings in a connection library, you must complete the following procedures:

  1. Add the secondary data connection to the form template.

  2. Bind controls to the query and data fields in the secondary data source.

  3. Configure the form template to use the data connection by using a rule or button.

Step 1: Add a secondary data connection

  1. On the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Search for connections on a Microsoft Office SharePoint Server, and then click Next.

  4. On the next page of the wizard, in the Site list, click the name of the site on a server running Office SharePoint Server 2007 with the connection library.

    My site is not on the list

    To add your site to the list, do the following:

    1. Click Manage Sites.

    2. In the Manage Sites dialog box, click Add.

    3. In the URL box, type the location of the data connection library.

    4. In the Display name box, type a name for the data connection library. This name will appear in the Site list in the Data Connection Wizard.

    5. Click OK.

    6. Click Close.

  5. Click the name of the data connection library to see a list of data connection files, click the name of the data connection file that you want to use for this data connection, and then click Next.

  6. Depending on the connection settings in the data connection file, the next page of the wizard may ask you to specify sample values for each parameter.

    How to specify sample values?

    1. Select a parameter in the Parameters table, and then click Set Sample Value.

    2. In the Sample value box, type a value that your user might use for this field, and then click OK.

    3. Repeat these steps for each parameter in the Parameters table, and then click Next.

    Technical Note

    When you configure a data connection to a Web service in the Data Connection Wizard, Microsoft Office InfoPath connects to the Web service and requests the Web Service Description Language (WSDL) file. The WSDL file contains the schema used by the Web service. The Web service responds to the request by sending this file to InfoPath. InfoPath uses the information in this file to add the appropriate fields and groups to the secondary data source in the form template. If InfoPath finds an unknown element type in the WSDL file, InfoPath uses sample data to determine the definition of the unknown element type and then adds the appropriate fields and groups to the secondary data source.

  7. If you want the results of the query to be available when the form is not connected to a network, select the Store a copy of the data in the form template check box.

    Security Note: Selecting this check box stores the query results in the form template. Because the data is stored in the form template, it is available in the forms that users fill out, even if their computers are not connected to a network. If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen.

  8. Click Next.

    The next page of the wizard will display a summary of the settings for this data connection.

  9. Type a descriptive name for the data connection. This name will appear in the Data Source list in the Data Source task pane.

  10. To enable forms based on this form template to use this data connection when they are opened, select the Automatically retrieve data when form is opened check box.

Top of Page

Step 2: Add a control to display the data to your users

  1. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  2. Drag a control onto the form template.

  3. In the Control Binding dialog box, select the field that you want to bind the control to, and then click OK.

Step 3: Configure the form template to use the data connection

If you want users to retrieve data from this data connection after the form opens, you can add a rule to your form template that uses the data connection under a certain condition, or you can add a button to your form template that your users can click to use the data connection.

Add a rule

You can add a rule to your form template that runs the query data connection whenever the condition for the rule is met. The following procedure assumes that you have created a query data connection for your form template, and that you have configured a control on your form template to display the data from the data connection.

  1. If the form template has multiple views, click View name on the View menu to go to the view with the control where you want to display the data from the secondary data source.

  2. Double-click the control that you want to add a rule to.

  3. Click the Data tab.

  4. Under Validation and Rules, click Rules.

  5. In the Rules dialog box, click Add.

  6. In the Name box, type a name for the rule.

  7. To specify a condition when the rule should run, click Set Condition, and then enter the condition. The rule will run when the condition occurs. If you do not set a condition, the rule will run whenever the user changes the value in the control, and then moves his or her cursor away from that control.

  8. Click Add Action.

  9. In the Action list, click Query using a data connection.

  10. In the Data connection list, click the query data connection that you want to use, and then click OK to close each dialog box.

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

Add a button to use the query data connection

You can add a button control to your form template that your users can click when they fill out a form based on your form template. When clicked, this button can retrieve data from the query data connection.

  1. If the form template has multiple views, click View name on the View menu to go to the view with the control where you want to display the data from the secondary data source.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Drag a button control onto your form template.

  4. Double-click the button control that you just added to your form template.

  5. Click the General tab.

  6. In the Action list, click Refresh.

  7. In the Label box, type the name that you want to appear on the button on your form template.

  8. Click Settings.

  9. In the Refresh dialog box, click One secondary data source.

  10. In the Choose the secondary data source list, click the secondary data source that is associated with the query data connection.

  11. Click OK to close each open dialog box.

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

Top of Page

Add a submit data connection

If the data connection file contains settings for a submit data connection, you can configure your form template to allow users to submit their form data through this data connection. When you configure your form template to allow users to submit their form data, InfoPath adds a Submit button on the Standard toolbar and a Submit command on the File menu. You can configure the submit options for the form template in the Submit Options dialog box (Tools menu). The submit options are configured in the same way as if you added a secondary data connection that is a submit data connection. Find links to more information about adding a submit data connection to your form template in the See Also section.

  1. On the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Search for connections on a Microsoft Office SharePoint Server, and then click Next.

  4. On the next page of the wizard, in the Site list, click the name of the site with the connection library.

    My site is not on the list

    To add your site to the list, do the following:

    1. Click Manage Sites.

    2. In the Manage Sites dialog box, click Add.

    3. In the URL box, type the location of the data connection library.

    4. In the Display name box, type a name for the data connection library. This name will appear in the Site list in the Data Connection Wizard.

    5. Click OK.

    6. Click Close.

  5. Click the name of the data connection library to see a list of data connection files, click the name of the data connection file that you want to use for this submit data connection, and then click Next.

  6. If the settings are for a submit data connection to a Web service, InfoPath can detect what parameters in the Web service can receive data. You can configure the submit data connection to send all of the data or part of the data in the form template.

    How?

    1. In the Parameters list, click a parameter that will receive the data from the form.

    2. To submit all of the data in the form for this parameter, including the root element and any processing instructions, do the following:

      1. Click Entire form (XML document, including processing instructions).

      2. To submit the data as a string, select the Submit data as a string check box. Typically, you select this check box to submit digitally signed data. In most cases, clear this check box.

    3. To specify a field or group for this parameter, do the following:

      1. Under Parameter options, click Field or group.

      2. Click Modify .

      3. In the Select a Field or Group dialog box, click the field or group whose data you want to submit, and then click OK.

      4. In the Include list, click Text and child elements only to submit just the content of the field or group, or click XML subtree, including selected element to submit both the content and the selected group or field.

    4. Repeat these steps for each parameter.

  7. Click Next.

  8. On the next page of the wizard, in the Enter a name for this data connection box, type a descriptive name for this submit data connection.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×