InfoPath 2003 provided a great way of creating forms that could connect and store data via a database, web services or XML files. InfoPath 2007 extends these options by providing the ability to use data connections stored in Microsoft SharePoint Server (MOSS), and the ability to submit data to a SharePoint list/document library, a hosting application such as a Windows form or via email.
This post provides a basic comparison of the data connection options that you should be aware of when designing your form using the InfoPath 2007 version.
Main vs. Secondary Data Connections
The first thing to note is that InfoPath allows one main data connection and multiple secondary data connections. The main data connection defines the main data source for the form, and is created automatically when you create a form based on an external data source. By default the data stored in the main data source is sent when the form is submitted. Combinations of the data connections may be used for secondary data sources. For example you might use an XML schema as your main data source but use a secondary database connection to retrieve information, and submit data through a web service. The options for your main data connection are described in the following sections.
Web Services
Using Web Services to retrieve and/or submit data adds an additional layer to your solution that can be used to perform additional validation or processing that cannot be provided within the InfoPath forms.
Pros/Cons
- Processing logic can be maintained in a central location – no need to re-deploy forms if application logic is updated (or if data store location changes)
- Supports complex data types such as rich text, file attachments and images
- No direct database access
Usage scenarios
Where MOSS is not an option, using Web Services as a data connection provides the most functional solution.
Database
A direct database connection is not suitable for most sizable business applications, but may be used to provide a quick and easy way to maintain small sets of data.
Pros/Cons
- Does not support complex data types including rich text (think bold, italics), file attachments, picture and ink controls.
- Requires ‘code behind’ if any processing is needed between the form and the database. For example, implementing concurrency or reading in CSV files.
- Cannot be used when submitting data from browser based forms
- Directly runs queries and updates on the database
Usage scenarios
This is ideal for applications that have basic data entry requirements, or for displaying information.
XML/Schema
Storing data in an XML file makes it easy to integrate the form’s data with other applications that may be part of your solution.
Pros/Cons
- May also require custom code to achieve desired functionality
- Supports complex data types such as rich text, file attachments and images.
- Works well when form is hosted in an custom application
Usage scenarios
This option works well if you are submitting data to the host application (Windows or Web form), a SharePoint document library or via email.
Data Connection Library
Data connection libraries allow you to share data connections, so this is useful if multiple forms use the same or similar data connections.
Pros/Cons
- Data connections are maintained in a single location – if your data source changes you only need to update this in one place
- A browser based form without full trust can connect to a computer in another domain
- Requires Microsoft Office SharePoint Server
Usage scenarios
This option provides a great way of managing the data connections when Microsoft Office SharePoint Server is available.
Additional Submit Options
In addition to the data connections mentioned above, InfoPath 2007 provides the ability to submit data to an application on a Web server, to a document library on a server running Microsoft Windows SharePoint Services, or in an e-mail message.
Summary
In this post I’ve given a brief description of the data connection options available in InfoPath 2007 including database vs. Web Services vs. XML. The next post in this InfoPath development series I’ll cover off the hosting environment options available, and how these can be used with the data connections described above.
For more information see the “Introduction to data connections” article on Microsoft Office Online