Data in First Repeating Section with controls updates all records in database - InfoPath Dev
in

InfoPath Dev

Data in First Repeating Section with controls updates all records in database

Last post 02-22-2010 01:14 PM by pikes1654. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-04-2010 02:02 PM

    Data in First Repeating Section with controls updates all records in database

    Hi,

     I have an Infopath form that receives and submits to a web service, which gets and updates records in a database. I can query the data, it will populate the repeating sections with the appropriate records, no problem. But if I make a change and submit, it will update all of the approprate records but only with the data in the first repeating section, obviously maintaining its unique pk. I need each repeating section to update its own record. Any help would be great, thanks in advance.

    This is my data layer that speaks with SQL:

    public static void UpdateEmployeeEducationList(string connectionString, List<EPSEmployeeEducation> ListOfEducations)

    {

    foreach (EPSEmployeeEducation education in ListOfEducations)

    Update(connectionString, education);

    }

    /// <summary>

    /// Updates the specified employee education.

    /// </summary>

    /// <param name="employee">The employee education.</param>

    public static void Update(string connectionString, EPSEmployeeEducation education)

    {

    SqlDataParameters args = new SqlDataParameters();

     

    args.AddInParameter(
    "@p_EmployeeEducationName", SqlDbType.NVarChar, education.EmployeeEducationName);

    args.AddInParameter("@p_Description", SqlDbType.NVarChar, education.Description);

    args.AddInParameter("@p_DateObtained", SqlDbType.DateTime, education.DateObtained);

    args.AddInParameter("@p_EmployeeId", SqlDbType.Int, education.EmployeeId);

    SqlDataHelper.ExecuteSproc(connectionString, "usp_EmployeeEducation_Update", args);

    }

    and this is my web service code: (there is no code behind the form)

    [WebMethod]
    public void UpdateEmployeeEducationByObject(List<EPSEmployeeEducation> education)

    {

    EPSEmployeeEducationData.UpdateEmployeeEducationList(

    Properties.Settings.Default.EPSConnectionString,

    education);

  • 02-08-2010 11:38 AM In reply to

    Re: Data in First Repeating Section with controls updates all records in database

     I think that I need to use XPathNodeIterator with while (.MoveNext()). But I dont know how to use that in the context of my code above. If any one could explicitly tell me what I should be doing I would GREATLY GREATLY appreciate it!!!!! Thanks in advance for your help!!
  • 02-22-2010 01:14 PM In reply to

    Re: Data in First Repeating Section with controls updates all records in database

    You do need to use an XPathNodeIterator with a while loop.

    Here is some pseudo-code. 

     

    // Create an XPathNavigator object for the form's main data source.

    XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

    // Create an XPathNodeIterator object for the new requests from your MAIN datasource.

    XPathNodeIterator xiNewRequests = xnDoc.Select("/my:myFields/my:gpRequests/my:gpRequest", ns); "my:ID"

    // See if any new requests have been added.

     if (xiNewRequests.Count > 0)

    {

        while (xiNewRequests.MoveNext())

        {

            // Put your processing logic here

       } // end While Loop

    }  // end if

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