skearney
(Shannon Kearney)
December 18, 2018, 4:08pm
1
I am trying to update a record that has already been written to UD15. I have successfully added a new record to UD15. Now I need to be able to click a button and update that same record in UD15.
I am getting this error:
My code is this:
//Order - Update and Send a Saved Order Ref
private void CallUD15AdapterUpdateMethod()
{
try
{
var Key1 = nbOrderRefNo.Value;
UD15Adapter adapterUD15 = new UD15Adapter(this.oTrans);
adapterUD15.BOConnect();
adapterUD15.GetByID(Key1);
adapterUD15.UD15Data.UD15[0].Key1 = "473";
adapterUD15.UD15Data.UD15[0].Key2 = "OrderHed";
adapterUD15.UD15Data.UD15[0].Key3 = tbOrderReferencePONumber.Text;
adapterUD15.UD15Data.UD15[0].Key4 = tbOrderReferenceCustomerID.Text;
adapterUD15.UD15Data.UD15[0].Key5 = "ORDERREF";
adapterUD15.UD15Data.UD15[0]["GS_ToEmail_c"] = "skearney@gill-line.com";
adapterUD15.UD15Data.UD15[0]["GS_BodyEmail_c"] = tbOrderRefEntryCS.Text;
adapterUD15.UD15Data.UD15[0]["GS_FromEmail_c"] = "customerservice@gill-line.com";
adapterUD15.UD15Data.UD15[0]["GS_IsSendReady_c"] = true;
adapterUD15.UD15Data.UD15[0]["GS_SubjectLine_c"] = "Order Ref PO Num: " + tbOrderReferencePONumber.Text;
adapterUD15.Update();
adapterUD15.Dispose();
}
catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
Banderson
(Brandon Anderson)
December 18, 2018, 4:16pm
2
I’m pretty sure you need all 5 keys on this one. Does it compile like that?
And you can’t change the Keys once they are created. (if that’s what you are trying to do…) You would have to delete and recreate.
skearney
(Shannon Kearney)
December 18, 2018, 4:20pm
3
I have all 5 keys in there. I don’t want to change the key I want to change one of the extended ud fields is all. that I am trying to do. I just put those 5 keys in there because I thought I would have to have them. This compiles fine with the code I had pasted above but I get that error when I try to test it.
Banderson
(Brandon Anderson)
December 18, 2018, 4:24pm
4
You only have one key in that call, If should look like this.
adapterUD15.GetByID(Key1,Key2,Key3,Key4,Key5);
And you need to set the values to what you want to look up.
So it should probably look like this.
adapterUD15.GetByID("473","OrderHed",tbOrderReferencePONumber.Text,tbOrderReferenceCustomerID.Text."ORDERREF");
That will pull in your record,
Then get rid of this, because that’s trying to set a key, which you can’t do.
adapterUD15.UD15Data.UD15[0].Key1 = "473";
adapterUD15.UD15Data.UD15[0].Key2 = "OrderHed";
adapterUD15.UD15Data.UD15[0].Key3 = tbOrderReferencePONumber.Text;
adapterUD15.UD15Data.UD15[0].Key4 = tbOrderReferenceCustomerID.Text;
adapterUD15.UD15Data.UD15[0].Key5 = "ORDERREF";
The rest should change your fields, and you should be able to update.
skearney
(Shannon Kearney)
December 18, 2018, 4:36pm
5
Thank you, that worked perfectly!