UpdateCollection examples
Inserting a new item
This sample demonstrates inserting a new item:
UpdateCollectionRequestData request = UpdateCollectionRequestData(); UpdateCollectionResponseData response; IDOUpdateItem customerItem = IDOUpdateItem(); request.IDOName = "SLCustomers"; request.RefreshAfterUpdate = ; customerItem.Action = UpdateAction.Insert; customerItem.Properties.Add("CoNum", "C000100"); customerItem.Properties.Add("Name", "New Company"); customerItem.Properties.Add("CreditHold", 1); request.Items.Add(customerItem); response = .Context.Commands.UpdateCollection(request);
Updating an existing item
This sample demonstrates updating an existing item queried through a LoadCollection request:
LoadCollectionResponseData loadResponse; UpdateCollectionRequestData request; UpdateCollectionResponseData response; IDOUpdateItem customerItem = IDOUpdateItem(); loadResponse = .Context.Commands.LoadCollection("SLCustomers", "CoNum, Name, CreditHold", "CoNum = N'C000100'", "", 1); if (loadResponse.Items.Count == 1) { request.IDOName = "SLCustomers"; request.RefreshAfterUpdate = ; customerItem.ItemID = loadResponse.Items[0].ItemID; customerItem.Action = UpdateAction.Update; customerItem.Properties.Add("CreditHold", 0); request.Items.Add(customerItem); response = .Context.Commands.UpdateCollection(request); }