Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

Problems saving a dataset with a Calculated expression.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R Neu - 15 May 2005 15:12 GMT
I'm having the same issue, but with a hierarchical dataset in a many-to-many relationship.
TASK|--< TASKSTEP >--|STEP

My data adapter is correct as currently, Im removing the Expression from the calculated fields using the code below and can save/update the database.

<CODE>
//Clear the calculated columns
foreach(System.Data.DataTable dt in hierarchicalDataSet.Tables)
    foreach (System.Data.DataColumn dc in dt.Columns)
    {
        if(dc.Expression.Length > 0)
        {
            if(dc.ExtendedProperties.ContainsKey("CalcExpression"))
                dc.ExtendedProperties["CalcExpression"] = dc.Expression;
            else
                dc.ExtendedProperties.Add("CalcExpression",dc.Expression);
            dc.Expression = "";
        }
    }
</CODE>

The problem is after the update.  I attempt to place the Expressions back and get an error of
"Object not set to an instance of an object." on execution of :
dc.Expression = strTestVar; in the code below.

<CODE>
foreach(System.Data.DataTable dt in hierarchicalDataSet.Tables)
    foreach (System.Data.DataColumn dc in dt.Columns)
    {
        if(dc.ExtendedProperties.ContainsKey("CalcExpression"))
        {
            try
            {
                strTestVar = dc.ExtendedProperties["CalcExpression"].ToString();
                dc.Expression = strTestVar;
                dc.ExtendedProperties.Remove("CalcExpression");
            }
            catch(Exception ex)
            {
                string str1 = ex.Message;
            }
        }
    }
</CODE>

At first I thought the Expression was invalid, but if I add the following it will add the duplicate column with the Expression.

dt.Columns.Add(dc.ColumnName + "Duplicate" , dc.DataType, strTestVar);

Any thoughts??
christian kuendig - 16 May 2005 17:03 GMT
I suggest not using expressions at all

my experience is:

   -it's kinda buggy

   -I've not really understood the sense for placing the derivation logic
of derived attributes with a proprietary syntax into a schema (just because
a layer of abstraction is missing between the datasets and the ui widgets
;-))

using many-to-many relationships in a dataset doesn't work when you're in a
3-Tier scenario and using identity columns (lost of original client side row
identity)

I had some success when I accepted changes before resetting expression
strings

regards

Chris

> I'm having the same issue, but with a hierarchical dataset in a
> many-to-many relationship.
[quoted text clipped - 59 lines]
>
> <Id>pXxnebWg40eXxyqZM4C3Vw==</Id>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.