E
Earl
I've been struggling with this data relation issue for awhile now. I've
found the source of the problem, but am unsure how to resolve this so I can
get the functionality I need. This would seem to be very common
functionality, but I do not see how it is done. Yes, I could just populate
the datagrid using an additional call back to the server with a JOIN, but
surely two trips to the server for the same data is not how the disconnected
motif of .Net is supposed to be implemented!
Fundamentally, it appears that what I'm trying to do is add rows to a table
where 3 of the columns are read-only, since they were added from the Parent
table to the child table. Thus an exception is raised on Update. Here I add
the 3 columns from the parent table to the child table and then later try to
Update the suppliers table.
I think my distilled question becomes: do I need to drop these columns from
the supplier table before doing the Update? If so, how? Is there a different
syntax for applying the Update to the child table? Or is there a way to make
those columns not read-only so it will accept the Update?
relSuppliers = New DataRelation("CityStateZipSupplier", _
dsWinMatrix.Tables("dtSupplierZips").Columns("ZipCityStateID"), _
dsWinMatrix.Tables("dtSuppliers").Columns("SupplierZipCityID"), False)
dsWinMatrix.Relations.Add(relSuppliers)
dsWinMatrix.Tables("dtSuppliers").Columns.Add("City", GetType(String),
"Parent(CityStateZipSupplier).City")
dsWinMatrix.Tables("dtSuppliers").Columns.Add("State", GetType(String),
"Parent(CityStateZipSupplier).State")
dsWinMatrix.Tables("dtSuppliers").Columns.Add("Zip", GetType(String),
"Parent(CityStateZipSupplier).Zip")
.....
da.Update(dsChanges, "dtSuppliers")
found the source of the problem, but am unsure how to resolve this so I can
get the functionality I need. This would seem to be very common
functionality, but I do not see how it is done. Yes, I could just populate
the datagrid using an additional call back to the server with a JOIN, but
surely two trips to the server for the same data is not how the disconnected
motif of .Net is supposed to be implemented!
Fundamentally, it appears that what I'm trying to do is add rows to a table
where 3 of the columns are read-only, since they were added from the Parent
table to the child table. Thus an exception is raised on Update. Here I add
the 3 columns from the parent table to the child table and then later try to
Update the suppliers table.
I think my distilled question becomes: do I need to drop these columns from
the supplier table before doing the Update? If so, how? Is there a different
syntax for applying the Update to the child table? Or is there a way to make
those columns not read-only so it will accept the Update?
relSuppliers = New DataRelation("CityStateZipSupplier", _
dsWinMatrix.Tables("dtSupplierZips").Columns("ZipCityStateID"), _
dsWinMatrix.Tables("dtSuppliers").Columns("SupplierZipCityID"), False)
dsWinMatrix.Relations.Add(relSuppliers)
dsWinMatrix.Tables("dtSuppliers").Columns.Add("City", GetType(String),
"Parent(CityStateZipSupplier).City")
dsWinMatrix.Tables("dtSuppliers").Columns.Add("State", GetType(String),
"Parent(CityStateZipSupplier).State")
dsWinMatrix.Tables("dtSuppliers").Columns.Add("Zip", GetType(String),
"Parent(CityStateZipSupplier).Zip")
.....
da.Update(dsChanges, "dtSuppliers")