Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Child tables Saved when saveResult = RuleWarnings
Message
From
07/05/2008 14:31:53
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Child tables Saved when saveResult = RuleWarnings
Miscellaneous
Thread ID:
01315702
Message ID:
01315702
Views:
53
* UPDATE
* Before you read any further, the supposed error below is by design
* in MM .NET Developer's Guide - Saving DataSets using Business Objects
*
* RuleWarnings = 3 (Warnings only - data is saved)
*
* I had assumed that the data was NOT saved on RuleWarnings
* UNTIL the user confirmed "overriding" the warnings
* by clicking save a second time (Save Anyway).
* Which is the client's requirement.

MM.NET Version 2.4

I have code to save an mmBusinessWebPage: (please see comments: ***)
    private mmSaveDataResult DoBasicSave() 
    {
        // always save new comments (child table in example)
        // set status, date, user to comment in dsChild
        int rowAdded = ChildHelper.Add(eChild, oChild, eMdtUser.Logon,
            eParent.Status, NoteLocation.Comment, this.txtComments.Text);

        // Save the DataSet (automatically binds back)
        mmSaveDataResult saveResult = this.Save(this.oParent, this.dsParent);

        if (saveResult == mmSaveDataResult.RulesPassed)
        {
            // go back to list
            Response.Redirect("default.aspx");
        }
        else   // some kind of error
        {
            // *** if mmSaveDataResult.RuleWarnings
            // *** the child table is already saved!!!
            // *** now need to Delete() it, otherwise duplicated
            // *** if user saves DESPITE warnings

            // *** this only works when mmSaveDataResult.RulesBroken
            // *** as child table NOT saved
            // remove and record from child DataSet
            // (page logic inserts it programatically again
            if (rowAdded > -1)
            {
                ChildHelper.Remove(eChild, oChild, rowAdded);
            }

            // save data
            Session["dsParent"] = this.dsParent;
            Session["dsChild"] = oChild.GetCurrentDataSet(); 
        }
    }
Now the obvious workaround is to disconnect the child table from the parent and
        mmSaveDataResult saveResult = this.Save(this.oParent, this.dsParent);

        if (saveResult == mmSaveDataResult.RulesPassed)
        {
            // add new comment (child record)
            // ...

            // *** save child separately
            this.Save(this.oChild, this.dsChild);
            
            // go back to list
            Response.Redirect("default.aspx");
        }
        else   // some kind of error
        { ... }
But, I thought I'd point out the problem. Any suggestions?
Thanks!
Reply
Map
View

Click here to load this message in the networking platform