Submit/retrieve an entire InfoPath form to/from SQL Server

In this InfoPath demo video you will see how you can use a web service to submit or retrieve entire InfoPath 2010 forms to or from SQL Server 2008.

In recipe 90, you will learn how to write C# code in Visual Studio 2010 for a web service that can submit an entire InfoPath form to SQL Server. And in recipe 91, you will learn how to write C# code in InfoPath 2010 and in Visual Studio 2010 for a web service that can retrieve an entire InfoPath form from SQL Server.

Get more solutions from InfoPath 2010 Cookbook 3 which is available on
Watch next video: Auto-number InfoPath forms in a SharePoint form library

InfoPath demo video transcript:

Here I'm in SQL Server 2008 where I've got this database table that contains 3 columns of which the third column is an XML column in which I would like to store entire InfoPath forms. As you can see, the table currently contains 3 records.

I've already created an InfoPath form template that will be calling this web service to submit and retrieve data from the SQL Server database table.

Here I'm in SharePoint 2010, and I've already published the InfoPath form template to this form library. So if I add a new form, you'll see that as soon as the form opens, it retrieves data from the SQL Server database table and displays the records that are currently present in the table here in the drop-down list box.

I'll add a new form and call it form04.xml, my fruit will be pineapple, color yellow, I'll pick a date in April, and I'll say pineapple goes well with carrot, with pear, and with sweet potato.

So now when I hit Submit, the form itself will not be submitted to the form library, but will be submitted to the SQL Server database table. So if I refresh the data, you'll see that this is the form that I just submitted to SQL Server.

I can switch back to SharePoint, and add a new form, and then load the data that I just stored in SQL Server by selecting the form name here, and then clicking Load Form. And as you can see, this is the data from the form that I just submitted.

I can also load one of the previously submitted forms. I'll take form 2. Again, the form will call the web service, which will go to SQL Server, and then return the data from the SQL Server database table.


Related InfoPath Demo Videos:


Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers