enforcing FK constraints on datatables that are not in a DS

  • Thread starter Thread starter Sankar Nemani
  • Start date Start date
S

Sankar Nemani

Hi All,
I've created two datatables dtCountries and dtCities in
memory. I am able to create a FK constraint on dtCities
without adding these datatables to a dataset. But unless I
add them to a dataset I am not able to enforce the
constraint. Is there any way to enforce FK constraint
without adding them to a dataset?
TIA
Sankar
 
If one DataTable does not know about the other, how exactly do you expect
one DataTable to ask the other if a given FK is valid? The
DataSet/DataRelation is what lets the DataTable's commuicate.

Otherwise you need to implement your own code that checks that proposed rows
FK values exist in the other DataTable.
 
Back
Top