R
R Neu via .NET 247
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??
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??