Update Databse with InfoPath Repeating Table - InfoPath Dev
in

InfoPath Dev

Update Databse with InfoPath Repeating Table

Last post 04-03-2009 07:09 AM by tallfiji. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-02-2009 01:06 PM

    Update Databse with InfoPath Repeating Table

    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;
           
    }
    Form Screen Shot 

     

     

  • 04-03-2009 12:04 AM In reply to

    Re: Update Databse with InfoPath Repeating Table

    Hi

    I think you can write another Command text for updating the Service Area table and pass the RequirementID as ServiceRequirmentID and execute then ncommand for both tables.

    Madhuri
    http://www.ggktech.com
  • 04-03-2009 07:09 AM In reply to

    Re: Update Databse with InfoPath Repeating Table

    So this will work with more than one Service Area?  What do you mean "and execute then ncommand for both tables"?  Wouldn't I have to iterate through the relationship table?  If I do need to itereate, how do I pass the table in and then itereate through it?  Some example code would be extremely helpful.

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.