This constraint cannot be enabled as not all values have corresponding parent values
-
Good Day All i have a function that builds a Dataset from 3 Xml Files. Let me take this time to explain the xml files. There is Subjects.xml, this xml contains all the subjects and i have XML_Venue.xml that contains all the venues and i have TimeTableFull.xml it contains the times,Venues that the subjects will be attended at. Now that means TimeTableFull.xml has many occurances of subjects but on Different venues or same venues but different times. The Following code builds a dataset from the xml's
private DataSet CreateDataSet()
{
DataColumn[] keys = new DataColumn[1];
DataSet dsFinalTimeTable = new DataSet();
DataTable tbldt;tbldt = new DataTable("Subjects"); //Add Staff Table XmlDataDocument xmlDatadocStaff = new XmlDataDocument(); xmlDatadocStaff.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\Subjects.xml"); tbldt = xmlDatadocStaff.DataSet.Tables\["Subjects"\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //Add Venue Table tbldt = new DataTable("Venue"); XmlDataDocument xmlDatadocVenue = new XmlDataDocument(); xmlDatadocVenue.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\XML\_Venue.xml"); tbldt = xmlDatadocVenue.DataSet.Tables\["VENUE"\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //TimeTable tbldt = new DataTable("TimeTable"); XmlDataDocument xmlDatadocTimeTable = new XmlDataDocument(); xmlDatadocTimeTable.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\TimeTableFull.xml"); tbldt = xmlDatadocTimeTable.DataSet.Tables\[0\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //Setup RelationsTimeTable// DataRelation VenuesRelations = new DataRelation("VenueRel", dsFinalTimeTable.Tables\["Venue"\].Columns\["ID"\], dsFinalTimeTable.Tables\["Appointment"\].Columns\["ID"\]); DataRelation ModuleRelations = new DataRelation("ModuleRel",dsFinalTimeTable.Tables\["Subjects"\].Columns\["ID"\],dsFinalTimeTable.Tables\["Appointment"\].Columns\["subjectid"\]); dsFinalTimeTable.Relations.Add(VenuesRelations); dsFinalTimeTable.Relations.Add(ModuleRela
-
Good Day All i have a function that builds a Dataset from 3 Xml Files. Let me take this time to explain the xml files. There is Subjects.xml, this xml contains all the subjects and i have XML_Venue.xml that contains all the venues and i have TimeTableFull.xml it contains the times,Venues that the subjects will be attended at. Now that means TimeTableFull.xml has many occurances of subjects but on Different venues or same venues but different times. The Following code builds a dataset from the xml's
private DataSet CreateDataSet()
{
DataColumn[] keys = new DataColumn[1];
DataSet dsFinalTimeTable = new DataSet();
DataTable tbldt;tbldt = new DataTable("Subjects"); //Add Staff Table XmlDataDocument xmlDatadocStaff = new XmlDataDocument(); xmlDatadocStaff.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\Subjects.xml"); tbldt = xmlDatadocStaff.DataSet.Tables\["Subjects"\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //Add Venue Table tbldt = new DataTable("Venue"); XmlDataDocument xmlDatadocVenue = new XmlDataDocument(); xmlDatadocVenue.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\XML\_Venue.xml"); tbldt = xmlDatadocVenue.DataSet.Tables\["VENUE"\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //TimeTable tbldt = new DataTable("TimeTable"); XmlDataDocument xmlDatadocTimeTable = new XmlDataDocument(); xmlDatadocTimeTable.DataSet.ReadXml(@"J:\\Pilot Project\\App\_Data\\TimeTableFull.xml"); tbldt = xmlDatadocTimeTable.DataSet.Tables\[0\]; keys = new DataColumn\[1\]; keys\[0\] = tbldt.Columns\["ID"\]; tbldt.PrimaryKey = keys; dsFinalTimeTable.Tables.Add(tbldt.Copy()); //Setup RelationsTimeTable// DataRelation VenuesRelations = new DataRelation("VenueRel", dsFinalTimeTable.Tables\["Venue"\].Columns\["ID"\], dsFinalTimeTable.Tables\["Appointment"\].Columns\["ID"\]); DataRelation ModuleRelations = new DataRelation("ModuleRel",dsFinalTimeTable.Tables\["Subjects"\].Columns\["ID"\],dsFinalTimeTable.Tables\["Appointment"\].Columns\["subjectid"\]); dsFinalTimeTable.Relations.Add(VenuesRelations); dsFinalTimeTable.Relations.Add(ModuleRela
-
Hi Vuyiswa, Please correct the data's of subjectid column in Appointment table (TimeTableFull.xml). It contains wrong values that should match the 'ID' column values of subjects table. Thanks,
Gopal.S
Thank you very much. That was the case
Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/