J
Jeff Zuerlein
I have been trying to write a function that can take in
two datatables (Source, Destination), and add a column
from the source table to the destination table.
Example:
ds.Relations.Add("CustomerOrders", _
ds.Tables("Customers").Columns("CustomerID"), _
ds.Tables("Orders").Columns("CustomerID"))
ds.Tables("Orders").Columns.Add("CompanyName", GetType
(String), _
"Parent(CustomersOrders).CompanyName")
It works fine as long as all the tables are in the same
dataset. I would like for the Source and Destination
tables to be able to come from different datasets. When I
try to use the DataTable.Copy method, to bombs and tells
me "Object reference can't be set to instance of object."
If I don't run the Columns.Add line, the rest of the code
works great. Is there something happening that prevents
the copy method for completing when columns have been
added based on a relationship?
Jeff
two datatables (Source, Destination), and add a column
from the source table to the destination table.
Example:
ds.Relations.Add("CustomerOrders", _
ds.Tables("Customers").Columns("CustomerID"), _
ds.Tables("Orders").Columns("CustomerID"))
ds.Tables("Orders").Columns.Add("CompanyName", GetType
(String), _
"Parent(CustomersOrders).CompanyName")
It works fine as long as all the tables are in the same
dataset. I would like for the Source and Destination
tables to be able to come from different datasets. When I
try to use the DataTable.Copy method, to bombs and tells
me "Object reference can't be set to instance of object."
If I don't run the Columns.Add line, the rest of the code
works great. Is there something happening that prevents
the copy method for completing when columns have been
added based on a relationship?
Jeff