Sep 3, 2008

Save Infopath Data into Database.

1. Create a webservice in asp.net.

1. Click on new open in file menu and select website and then select asp.net we bservices.
2. Add a webmethod in .cs file.

[WebMethod]
public
void InsertVillage(int villageId,string CatA,string DDLA,string CatB,string DDLB)
{
cmd =
new SqlCommand("select * from Entry", con);
mydataset =
new DataSet();
myadapter =
new SqlDataAdapter(cmd);
myadapter.Fill(mydataset);
string
strsql = string.Empty;
strsql =
"insert into Entry values(" + villageId + ",'" + CatA + "','" + DDLA + "','" + CatB + "','" + DDLB + "')";
cmd.ExecuteNonQuery();
}

(ii) After binding all the controls double click the button through which you want to submit the data.Select Submit option from Action dropdown list.The page look likes:














Now click on Submit Options.. button.

(ii) Select Web service option from first dropdown list.If you have already added a data connection, you can choose from second dropdown list or click Add button to add a new data connection.The popup window looks like:
















(iii) Enter your web services address.













(iv) Select Submit data option.













(v)Choose the first option to submit data through web service.

0 comments: