Create Data Connection in InfoPath in SharePoint

This InfoPath tutorial explains, how to create a data connection from a SharePoint 2010 list in InfoPath 2010. We need to create data connections to retrieve data from other lists in InfoPath 2010 in SharePoint 2010. We will check below things:

  • Create Data Connections in InfoPath 2010 in SharePoint 2010
  • Create XML data connection in InfoPath in SharePoint 2010
  • Create SQL data connection in InfoPath in SharePoint
  • How to create a udcx file for Main Data Connection in InfoPath

Create Data Connections in InfoPath 2010 in SharePoint 2010

Follow below steps to create a data connection in InfoPath 2010 in SharePoint 2010.

Step-1:
Open InfoPath 2010 (Start -> All Programs -> Microsoft Office -> Microsoft InfoPath Designer 2010), then select Blank Form and Click on Design Form.

Step-2:
From the Ribbon select Data tab and select Data Connections as shown in the figure below:

create data connection in infopath

Step-3:
In the Data Connections wizard click on Add… as shown in the figure below:

create data connection in infopath 2010

Step-4:
In the next step select Create a new connection to Receive data and click on Next as shown in the figure below:

create data connection in infopath 2013

Step-5:
In the next step select SharePoint library or list and click Next as shown in the figure below:

create data connection in infopath sharepoint

Step-6:
In the next step give the SharePoint site details and Click on Next as shown in the fig below:

create data connection in infopath 2010 sharepoint

Step-7:
Then Select the list from which you want to bind the data as shown in the fig below:

create data connection in infopath 2013 sharepoint

Step-8:
In the next step, select the fields which you want to retrieve and sort order and click on Next as shown in the fig below:

how to create data connection in infopath

Step-9:
Then click on Next and do not modify anything for Store a copy of the data in the form template.

Step-10:
Then give a name for the data connection and select the checkbox. Automatically retrieve data when form is opened as shown in the fig below and click on Finish.

how to create data connection in infopath 2013

This creates a data connection in InfoPath 2010 in SharePoint 2010.

Create XML data connection in InfoPath in SharePoint 2010

Create XML data connection in InfoPath in SharePoint 2010

Now, we will discuss how to create a data connection in an XML file in InfoPath 2010 in SharePoint 2010.

Below are the steps on how to create a data connection with XML file in InfoPath:

Suppose we want to retrieve some field data like first name, last name etc. So we first we have to create XML file. Just copy the below code and paste it on a notepad and save it as template.xml.

<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Continue">
<Method ID="1" Cmd="New">
<Field Name=’Title’></Field>
<Field Name="FirstName"></Field>
<Field Name="LastName"></Field>
<Field Name="Email"></Field>
<Field Name="Phone"></Field>
</Method>
</Batch>

Now open a blank form library. Open InfoPath designer 2010 Go to Data tab, click on data connection and then click on Add.

Now choose your type of connection to submit data/receive data and click on Next.

Create XML data connection in InfoPath in SharePoint 2010

Now choose XML document from the radio buttons and click on Next.

Create XML data connection in InfoPath sharepoint 2010

Now click on browse and choose your xml file as we created “template.xml”.

Create XML data connection in InfoPath in SharePoint 2010

Now click on next and lastly provide the data connection name as you want. Now your XML data connection is ready to retrieve data inside InfoPath 2010 form.

Create SQL data connection in InfoPath in SharePoint

In this SharePoint 2013 InfoPath tutorial, I am going to explain how to create SQL data connection in InfoPath 2013 and how to get the data from SQL table into your InfoPath form in SharePoint 2013.

Open your InfoPath form and click on the DATA tab from the ribbon. Then click on Data connection and then click on Add. Now from the dialog box check on “Receive Data”. Now from the next dialog box choose “Database”.

Now click on select Database and click on “Connect to New Data source” and open. From the data connection wizard choose “Microsoft SQL Server”, Now it will ask for your SQL server name.

Create SQL data connection in InfoPath in SharePoint

Give the server name->next and choose windows authentication or SQL authentication as per your requirement. In the next dialog box select your database and then choose your desired table and click on next. In the next dialog box, you can change the name or you can keep that name.

In the next dialog box, check on your desired columns and then click on next->next. In this dialog box, you can give the name data connection or you can keep the name provided by the system and uncheck “Automatically retrieve data when the form is opened”.

Create SQL data connection in InfoPath in SharePoint 2013

Finally, click on finish and your data connection is created. This way we can create SQL data connection in InfoPath in SharePoint.

How to create a udcx file for Main Data Connection in InfoPath

Now, we will see how to create udcx file for the main data connection in InfoPath 2013 SharePoint 2013.

To create an UDCX file follow the below steps.

Step-1 Create a data connection library in InfoPath 2010

Open your SharePoint server and click on Add on the list, library and another app. Then click on the Data connection library and provide the name and click on create. Now your data connection library is created and now will go to the next step.

Step-2 Create udcx file in InfoPath

Open your InfoPath form and click on Data->Data connection. From the dialog box click on your data connection name you want to convert and then click on “Convert to connection file”. Now it will ask for the data connection path we created on step-1. Provide the udcx file name as below.

http://site url/dataconnection library name/udcx file name.

Then click on ok as shown in the fig below:

create a udcx file for Main Data Connection in InfoPath

Now go to your site and approve the udcx file uploaded in the data connection library. Now you can work with your udcx file using rules to retrieve data.

You may like following InfoPath tutorials:

Here, we saw how to create a data connection in InfoPath in SharePoint and also we saw below examples:

  • Create Data Connections in InfoPath 2010 in SharePoint 2010
  • Create XML data connection in InfoPath in SharePoint 2010
  • Create SQL data connection in InfoPath in SharePoint
  • How to create a udcx file for Main Data Connection in InfoPath
Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>