XForm Content

Vote:
 

Hi,

I am new learner of Episerver.I am trying to create the XForm in Episerver (Contact Us Form) I have created form and its also showing up in my page. How to I send  the data which is filled in my form to any database.

#44305
Oct 08, 2010 8:36
Vote:
 

Just add a submit button to your form. On the properties for that button, you are able to set wether it should post to email, post to email and store in database or store in database.

Select "Store in database", and you will get a "Form data" tab in your edit mode where you can find all posted data.

#44307
Oct 08, 2010 9:30
Vote:
 

Hey,

Thanks for the reply!

I am doing the same.How do i came to know in which table the values get stores.Like if i want to create new table and want to store  xform values inside it then what to do???

#44331
Oct 08, 2010 15:06
Vote:
 

You can either attach a event on the xforms-page when saving the form and save it to yout own table. You could also tell the XForm (in edit mode) to send the input parameters to another page, where you could take care of the input.

#44333
Oct 08, 2010 15:19
Vote:
 

and you can also just save the data in the EPi-DB table for the xforms as built-in, and programmatically use that table-data later to pick out any saved data from, very handy when you for example have courses people register to attend, you can first check how many persons are already booked and only show/enable-save-button the form if there are free spots to take. So each Xform becomes a data table virtually spoken :-)

#44376
Oct 11, 2010 13:39
Vote:
 

Hi,

Thanks for the reply.

Their is one thing ,I want to know ,suppose I selected save to database in my XForm onclick button , then in which table the content get stored.Lets consider its an Episerver database, I just created an XForm with save to databas eoption.Then how episerver  came to know in which table this data should stored.I have installed the demo site for episerver (Alloy technologies)inside it their is an Contact Form . On hit of the submit button , content is saved somewhere but where?????

#44378
Oct 11, 2010 13:47
Vote:
 

There's a new line in tblItem for each time a form is posted. (Name column contains xformdata_<GUID>)  Not that there's anything useful to do with the data.

As mentioned above, the best way is to programatically use the API to access the forms and fetch/change/post data.

#44379
Edited, Oct 11, 2010 14:01
Vote:
 

Hi,

So yoy mean to say their is no specific table in the database.

#44380
Oct 11, 2010 14:27
Vote:
 

You will not find you fields mapped to columns in a database no. It is stored as binary serialized objects. If you want data stored in database tables, you could handle the BeforeSubmitPostedData and store the data in your own table.

I'm not sure what your requirements are, but I would recommend working with the API to access your xform data.

#44381
Oct 11, 2010 14:44
Vote:
 

Remember EPiServer 6 uses the Dynamic Data Store to save xform data so it is theoretically accessible with a direct query on the database. However I'd advice using LINQ over the xforms store to get hold of the data. There is a good post by Linus Ekström explaining it here:

http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2010/7/Using-the-dynamic-data-store-with-XForms/

 

 

#44417
Oct 11, 2010 16:15
Vote:
 

Hi,

Thanks for the reply. I am trying to get the form values in the BeforesubmittedPostedData function. My form consist of two fields only one is name and other is info. But in this function ,I am getting none of them.

nither formData.info,nor formdata.name.

#44751
Oct 14, 2010 9:51
Vote:
 

control.Data.GetValue("name")  will give you the value of the textbox called name

public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
  XFormControl control = (XFormControl)sender;
  var name = control.Data.GetValue("name");
  ...
}

#44754
Edited, Oct 14, 2010 11:21
Vote:
 

Hi,

Thanks for the reply.I got both the values now in my page. Now I want to send this data in my externalDatabase not inside the episerver database.How do I connect to external database in episerver.

#44764
Oct 14, 2010 13:22
Vote:
 

Do just like you would do in any .NET application, there aren't (not to my knowledge) any special helpers for performing tasks in other databases in EPiServer.

Edit: Sorry to cut the line before you there Lars Øyvind, your answer was much more helpful :)

#44765
Edited, Oct 14, 2010 13:31
Vote:
 

There's no EPiServer magic, use regular .Net code.

SqlConnection connection = new SqlConnection("your connectionstring");
connection.Open();
// To use a stored procedure:
try
{
    SqlCommand command = new SqlCommand("storedProcedureName");
    command.Connection = connection;
    command.CommandType = CommandType.StoredProcedure;
    command.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException)
{
    // Log error or something
}
connection.Close();
SqlConnection connection = new SqlConnection("your connectionstring");connection.Open();
// To use a stored procedure:
try{    
SqlCommand command = new SqlCommand("storedProcedureName");    
command.Connection = connection;    
command.CommandType = CommandType.StoredProcedure;    
command.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException){    
// Log error or something
}
connection.Close();
#44767
Oct 14, 2010 13:33
Vote:
 

Ahhhh. And refresh the page before posting answers :-D  (You were too fast Magnus)

#44768
Oct 14, 2010 13:34
Vote:
 

Hi,

Thanks for the reply. ...............:)

#44769
Oct 14, 2010 13:34
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.