Check out Best Alternative to InfoPath -> Try Now
This InfoPath 2010 tutorial explains, What is the difference between the main data source and secondary data sources in InfoPath 2010 in SharePoint 2010.
Every data showed in an InfoPath form, is stored in form’s data source. A data source contains fields and groups. Then suppose you add a control then this control is bound to those fields.
There are 2 types of data sources in InfoPath 2010:
- Main data source
- Secondary data sources
A form will have a single main data source by default and may or may not contain one or more secondary data sources.
SharePoint 2016 Tutorial Contents
Main data source in InfoPath 2010
The main data source in InfoPath 2010 contains the data that users add when they fill out a form that is based on the form template, such as the data that they enter into a text box.
It also contains the data from a data connection to a database or Web service, which is used to define the data source of the InfoPath 2010 form template.
When you create a form template, Microsoft Office InfoPath automatically creates the main data source.
Secondary data sources in InfoPath 2010
Secondary data sources are data sources in the form that contain data supplied through other data connections to external data sources.
The data from additional data connections is stored in secondary data sources and then displayed. You can check this article to know how to create a data connection in InfoPath 2010.
Difference between the Main data source and Secondary data sources:
- Secondary data sources are optional in a form template. But all form templates must have the main data source.
- A form template can have one or more secondary data sources but only a single main data source.
- Fields and groups in a secondary data source are based on the way that data is stored in the external data source, which is connected to the form by using a data connection. These fields and groups cannot be modified by using InfoPath.
- Unlike the main data source, secondary data sources are not saved with the form.
Data in secondary data sources are not typically submitted when the user submits a completed form. However, you can configure your form template to submit the data in the secondary data source to a Web service by using rules or to an e-mail recipient by using custom code.
Programmatically access data sources in InfoPath 2010
Main Data Source:
Below is the code to access the main data source using C#.Net code in Infopath 2010:
XPathNavigator mds = MainDataSource.CreateNavigator();
Secondary data source:
Below is the code to access the secondary data source using C#.Net code in InfoPath 2010:
XPathNavigator sds = DataSources[“dataconnectionName”].CreateNavigator();
XPathNavigator sds = DataSources[“Employees”].CreateNavigator();
Here are few very good points I am adding which I got to know from bizsupportonline URL.
The Main InfoPath data source of a form contains the data that you want to permanently store when you save the form in InfoPath 2010 in SharePoint 2010.
You may like following InfoPath 2010 tutorials:
- Change code language to C#.Net in InfoPath 2010 in SharePoint 2010
- Create Data Connection in InfoPath in SharePoint
- InfoPath designer repeating table example
- Change different view in InfoPath 2010 based on certain condition
- Option button in InfoPath 2010 in SharePoint 2010
- Add multiple lookup column to SharePoint 2010 list InfoPath 2010 form
- Print multiple InfoPath form views in SharePoint
- Calculate Age based on Date of Birth in date picker in InfoPath
- Get Manager Details for Logged in User in InfoPath
- InfoPath Add action rule to people picker in SharePoint 2013
- Disable Save button in list form in InfoPath 2013 in SharePoint
- Check more than 5 conditions in InfoPath 2013 Rule
- Declare Hidden Variable in InfoPath 2013/2010
- Add hyperlink in InfoPath 2013 in SharePoint 2013
The secondary data source is like a temporary storage location for the data that is external to the form. The data in the secondary data sources of the form is never saved in the form when we save the form. So if you want data to be present in a form after you save, close, and re-open the form, you have to store this data in the Main data source of the InfoPath form.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.