Code does nothing in .NET 2.0

  • Thread starter Thread starter Marco Wolff
  • Start date Start date
M

Marco Wolff

Hi,

i'm updating some sources from .NET 1.0 to .NET 2.0 and some very strange
things happen, for example:

DataSet1.Tables["Customers"].ChildRelations[0].ChildColumns[0] =
DataSet1.Tables["Orders"].Columns["test"];

In .NET 1.0 "DataSet1.Tables["Customers"].ChildRelations[0].ChildColumns[0]"
is always "Columns["test"]". But now, nothing happens, the ChildColumns (on
the left side) are always stays the same, no Exception nothing.

For me this is very critical stand, because nothing happens and no Exception
is throwing.

Please help.

Marco
 
You can reproduce this bug by your own, try this:

DataSet DataSet1 = new DataSet();
DataTable customers = new DataTable("Customers");
customers.Columns.Add("CustID");
DataSet1.Tables.Add(customers);

DataTable orders = new DataTable("Orders");
orders.Columns.Add("CustID");
orders.Columns.Add("test");
DataSet1.Tables.Add(orders);

// Get the DataColumn objects from two DataTable objects
// in a DataSet. Code to get the DataSet not shown here.
DataColumn parentColumn =
DataSet1.Tables["Customers"].Columns["CustID"];
DataColumn childColumn =
DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentColumn,
childColumn, true);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);

DataSet1.Tables["Customers"].ChildRelations[0].ChildColumns[0] =
DataSet1.Tables["Orders"].Columns["test"];


If you try this under .NET 1.0
DataSet1.Tables["Customers"].ChildRelations[0].ChildColumns[0] = "CustID"

In .NET 2.0 DataSet1.Tables["Customers"].ChildRelations[0].ChildColumns[0] =
"test"

Thanks

Marco
 
Back
Top