G
Guest
Hi
Like many others, I have fallen victim to the endless hours of Google searching and newsgroup scouring in trying to troubleshoot an issue with the DataColumn's expression property
I have two tables, a Parent table and Child table. The Child table has a column whose Expression property is set to the value in a Parent column (i.e. ChildColumn.Expression = "Parent.ParentColumn"). I have had extensive issues in using a DataAdapter to update these two tables. Everything from VersionNotFoundExceptions to ArgumentExceptions (cannot find relation 0) has come across my screen. The core issue that everyone seems to face involves these expression columns. The recommendation I've seen basically says to remove the expression columns before trying to update the data in the table(s). I would have no issue with that; however, here's my issue
I go through each of the child columns and remove the expression-based columns. I then go through the parent columns and remove the expression-based columns. The issue is that one of the child columns' expressions points to a parent column's expression. When I go to remove the parent column, I get a message that I cannot remove the column because it belongs to another columns expression. However, I removed that column from the child, so it shouldn't be part of anyone's expression
Is there something more I have to do to the column than "Remove" in order for all of the other tables/columns/relations to know that the column no longer requires it in its expression
An example of code
Public Sub example(
Dim parent As DataTable = New DataTabl
Dim child As DataTable = New DataTabl
parent.Columns.Add(New DataColumn("ID", GetType(Integer))
parent.Columns.Add(New DataColumn("Expression", GetType(Integer), "ID * 2")
child.Columns.AddRange(New DataColumn() {
New DataColumn("ID", GetType(Integer)),
New DataColumn("ParentID", GetType(Integer))}
Dim ds As DataSet = New DataSe
ds.Tables.AddRange(New DataTable() {parent, child}
ds.Relations.Add(New DataRelation("ParentChild", parent.Columns("ID"), child.Columns("ParentID"))
child.Columns.Add(New DataColumn("ParentExpression", GetType(Integer), "Parent.Expression")
'Now, try to remove the columns in reverse
child.Columns.Remove("ParentExpression"
parent.Columns.Remove("Expression") ' this generates the "Cannot remove" erro
End Su
I have also tried to set the child columns expression value to be String.empty prior to removing it; however, this generates an exception "Object or null reference" during the call to child.Columns.Remove(column)
THIS IS SO FRUSTRATING!!!!!!!!!!
Like many others, I have fallen victim to the endless hours of Google searching and newsgroup scouring in trying to troubleshoot an issue with the DataColumn's expression property
I have two tables, a Parent table and Child table. The Child table has a column whose Expression property is set to the value in a Parent column (i.e. ChildColumn.Expression = "Parent.ParentColumn"). I have had extensive issues in using a DataAdapter to update these two tables. Everything from VersionNotFoundExceptions to ArgumentExceptions (cannot find relation 0) has come across my screen. The core issue that everyone seems to face involves these expression columns. The recommendation I've seen basically says to remove the expression columns before trying to update the data in the table(s). I would have no issue with that; however, here's my issue
I go through each of the child columns and remove the expression-based columns. I then go through the parent columns and remove the expression-based columns. The issue is that one of the child columns' expressions points to a parent column's expression. When I go to remove the parent column, I get a message that I cannot remove the column because it belongs to another columns expression. However, I removed that column from the child, so it shouldn't be part of anyone's expression
Is there something more I have to do to the column than "Remove" in order for all of the other tables/columns/relations to know that the column no longer requires it in its expression
An example of code
Public Sub example(
Dim parent As DataTable = New DataTabl
Dim child As DataTable = New DataTabl
parent.Columns.Add(New DataColumn("ID", GetType(Integer))
parent.Columns.Add(New DataColumn("Expression", GetType(Integer), "ID * 2")
child.Columns.AddRange(New DataColumn() {
New DataColumn("ID", GetType(Integer)),
New DataColumn("ParentID", GetType(Integer))}
Dim ds As DataSet = New DataSe
ds.Tables.AddRange(New DataTable() {parent, child}
ds.Relations.Add(New DataRelation("ParentChild", parent.Columns("ID"), child.Columns("ParentID"))
child.Columns.Add(New DataColumn("ParentExpression", GetType(Integer), "Parent.Expression")
'Now, try to remove the columns in reverse
child.Columns.Remove("ParentExpression"
parent.Columns.Remove("Expression") ' this generates the "Cannot remove" erro
End Su
I have also tried to set the child columns expression value to be String.empty prior to removing it; however, this generates an exception "Object or null reference" during the call to child.Columns.Remove(column)
THIS IS SO FRUSTRATING!!!!!!!!!!