I need to have an infopath form update a SQL server
database with information using a web service. I have already been
able to create the form to update the table known as Requirements. I,
however, have an associated table called ServiceArea_Requirements that
is a relationship between Requirements and Service Areas that also
needs to be updated. Can someone help me understand how to update the
Service Area to Requirement table from the InfoPath repeating table?
The Web Service Code I have built to date is below. This will update
the Requirement information. I'm not sure how to do the relationships
though. I've also attached a screen shot of what the form looks like
right now.
Code:
[WebMethod]
public bool UpdateRequirement(int RequirementID, string RequirementName, string Description, int Category, int Type)
{
try
{
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["dbConnection"];
DbProviderFactory pf = DbProviderFactories.GetFactory(cs.ProviderName);
using (DbConnection c = pf.CreateConnection())
{
c.ConnectionString = cs.ConnectionString;
DbCommand cmd = c.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "uspUpdate_Requirement " + " '" + RequirementName + "' " + ", " + RequirementID + ", " + " '" + Description + "' " + ", " + Category + ", " + Type;
c.Open();
int recordsAffected = cmd.ExecuteNonQuery();
}
}
catch (Exception)
{
return false;
}
return true;
}