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>