Function - UD Child Add New, Getting "the table has more than one record" error


If UD child table has no records the following code works fine:

this.CallService<Ice.Contracts.UD101SvcContract>(svcUD101 => {

    var tsUD101 = svcUD101.GetByID(BundleID,"","","","");
    svcUD101.GetaNewUD101A (ref tsUD101, BundleID, "", "", "", "");
    var UD101ANew = tsUD101.UD101A.Where(r=>r.Added()).FirstOrDefault();
    UD101ANew["Company"] = Session.CompanyID;;
    UD101ANew["Key1"] = BundleID;
    UD101ANew["Key2"] = String.Empty;
    UD101ANew["Key3"] = String.Empty;
    UD101ANew["Key4"] = String.Empty;
    UD101ANew["Key5"] = String.Empty;
    UD101ANew["OrderNum_c"] = OrderNum;
    UD101ANew["OrderLine_c"] = OrderLine;
    UD101ANew["OrderRelNum_c"] = OrderRel;
    UD101ANew["Quantity_c"] = Qty; 
    UD101ANew["Character01"] = LotNum;
    UD101ANew["Character02"] = "WCAS";
    UD101ANew["Character03"] = "RECEIPTBIN";

    //UD101ANew["RowMod"] = "A";
    svcUD101.Update (ref tsUD101);

If more than one record exists it still adds the line but I get:

Any ideas?

many thanks


I think it’s getting goofed on identifying the right row
after you call getanewUD100A, you could try setting the row number to 1 minus the last row

int rc = UDAdapter.UD100Data.UD100A.Rows.Count -1;
							DataRow drA = UDAdapter.UD100Data.UD100A.Rows[rc];
								drA["ChildKey1"] = DateTime.Now.ToString();
								drA["ChildKey2"] = QuoteNum;					
								drA["Character01"] = "Allocated";
								drA["Number01"] = CustNum;
							resultUpdate = UDAdapter.Update(); 
1 Like

Hi Aaron,
Thanks for replying - I did try this already but still the same issue.
Kind regards


You could make your life easier and do it with widgets :slight_smile:

1 Like

I’ll give that a whirl - I guess I’m a little old fashioned :slightly_smiling_face:

1 Like