StrataFrame Forum

Save method changes currentrow?

http://forum.strataframe.net/Topic4577.aspx

By Greg McGuffey - 11/16/2006

I noticed that when I call Save() from code, the current row is changed. I was saving changes to two rows. I used the SeekByPrimaryKey() to navigate to the rows to change, change the data via properties, then saved using Save. After I was done, the first row in the BO was the current row. This row wasn't involved in the changes. There is a Sort set on the BO. What's up? Is this normal? Why? Inquiring minds want to know! Wink


By Trent L. Taylor - 11/17/2006

We do not sort the BO anywhere in the code explicitly.  We will remember this setting in certain cases.  As for the row, it should end back up on the same row.  The only way it would not is if you have AutoNavigateToFirstBrokenRow set to True, which by default it is, then that row has broken rules that need to be corrected.  We do move through the rows when checking broken rules, but we ALWAYS end back up on the initial row unless you have forcefully moved the record position or you have broken rules and the AutoNavigateToFirstBrokenRow is set to True and another row had a broken rule.
By Greg McGuffey - 11/17/2006

hmmmm...it sure was last night. Could this sort of thing be caused if I'm not cleaning up after myself (not disposing of BOs created in code for example)? I just read that bit yesterday and I'm probably not doing a good job of that yet. Blush
By Trent L. Taylor - 11/17/2006

Obviously I do not know what your code is doing, but the number one killer of many .NET developers is not cleaning up after the code and expecting the garbage collector to do the work.  The other thing, that goes hand in hand here, are event handlers.  If you ever gain a handler reference to any object, not just a BO, it will stay there until you explicitly remove the handler.  The issue you are describing sounds more like an event handler issue to me...but you will definitely want to Dispose your manually created objects when you are through with them...whether it be a BO or some other type of object.
By Greg McGuffey - 11/17/2006

So, if I'm just using the WithEvents in the declare and then Handles for the specific event, how do I clean that up?
By StrataFrame Team - 11/17/2006

You don't Smile

Unlike the AddHandler/RemoveHandler, the WithEvents/Handles combo does not have a way remove the handler.  However, they get cleaned up when the class handling the event is disposed and garbage collected.

By Greg McGuffey - 11/17/2006

Ah, OK. I'm going to check my code now....time to take out the garbage BigGrin
By Greg McGuffey - 11/17/2006

If I have a reference to a BO in code and then a reference to that BO's datatable, do I need to dispose of the datatable explicitly? Or does disposing of the BO handle both?
By StrataFrame Team - 11/17/2006

Disposing of the BO handles both... in the Dispose() method of the BO, we handle the call to CurrentDataTable.Dispose().
By Greg McGuffey - 11/17/2006

Great!