dataset relations problem please help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a dataset with many tables in it. Two of them are Persons and
Objects. An object may or may not belong to a person. I'm reading in an XML
document for my data source and creating a parent/child relationship between
Persons(parent) and Objects(child). When the object doesn't belong to a
person, there is no value in the Person_Id node of the Objects table. Null
is a valid value for the Person_Id in the objects table in my DB. When I
have a value for Person_Id in my objects table everything works fine when I
use the data adapter update method to insert the data. When an Object has a
null node for Person_Id, I'm getting an error that the constraint can't be
created.

Its obvoius why this is happening, but I need to know if there is some way I
can tell the dataset/dataadapter/relation objects to only check the
parent/child relationship when a Person_Id exists in my object?
 
You have to be sure the property minoccurs of your Person_Id field is set to
0 in the Objects table in the dataset xsd file.

Hope this helps.
 
Unfortunately, the minoccurs in the xsd generated by the dataset is 0
already. If only there were some way to tell the system to only apply the
constraint to records where Person_Id is not null...
 
Wait, hold the phone... I just had to remove the empty node for the
<Person_Id> from the Object node... once the node was gone it worked. Which
makes sense since minoccurs = 0. If the node is there, it takes the
<Person_Id> value to be null which of course does not match a value in the
<Persons> table.

Thanks for the tip!
 
Back
Top