Error is
Error: CS0120 - line 340 (6052) - An object reference is required for the non-static field, method, or property ‘Ice.Adapters.UD110Adapter.UD110Data.get’
Spoke too soon darn it.
It is updating the correct UD110 but still not the correct UD110A. Somehow I am not telling it to update that record. So frustrating. Anyone know what I’m doing wrong?
Are you writing this on the UD110.dll form as a form customization?
I don’t quite understand the adapterUD110.UD110Data.UD110A.Rows object… Are those all of the rows that are currently in the session since you used UD110Adapter(this.oTrans); ?
If that is the case, okay cool, I learned something, but it really confuses me too. Are these rows the same rows that are in the UD110A dataview?
In any case, say that does return all of the rows linked to your current oTrans session… I see you looping through each one of those rows until you find a match.
What I don’t see you doing is finding the row number that matches and then updating that row number specifically. I see you using the value 0 in this statement:
I thought that 0 meant the first row in the table. If it isn’t the first row in the table that matches your criteria, what happens… maybe that is what is happening here. Maybe it isn’t the first child row that matches your criteria yet you are updating the first row anyways.
No I have added UD110 as a DataView to the Equipment form customization.
Once it finds the appropriate UD110 record then it is looping thru all of the UD110A child records to see if any meet the criteria I am looking for in the ChildKey’s.
You are exactly correct. I am not finding the row number that matches and then updating that row number because I don’t know how to do that. How do I get the number and then update just that row.
Okay, I think you are on to something here. I added the part about GetRowEnumerator on the for each. It is still not updating the correct row so there is something I need to still get correct in that part.
I agree, first verify you are getting in the ultra grid row loop like you expect. Put a message box in your for each, right before
bool checkstatus = true;
Once in the loop over the ultra grid rows, you still to loop over the UD100A rows to find the right one, as @utaylor showed above(break out of the for each loop once you find your match).
@skearney I don’t know if this will work for you because I don’t know where you are calling this from or if you are trying to update this using a business logic method call, but if you have the UD110A dataview in your form at the time this method is ran, I believe you can do this:
I borrowed some code from @hkeric.wci to create a table that only has the rows you want in it. That way you don’t have to loop through the whole UD110A child table if only SOME of the rows are matching your criteria. For example, if you had 100 child rows, but only two matched, the foreach loop you wrote would have to go through all of them. I think this way that I copied from @hkeric.wci may be more efficient (I don’t really know though). It creates a table that you can then loop through and change.
I added the message box and it is finding a record that matches. It is updating the first keys it finds for the UD110 table but it isn’t picking the correct UD110A record. I just need to figure out how to tell it which record to update. @utaylor
Try updating your loop to this:
Also, I think you may have been disposing the adapter to soon(if there may be more than row), i wrapped it in a using statement and opened up the scope a bit.