Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. This constraint cannot be enabled as not all values have corresponding parent values

This constraint cannot be enabled as not all values have corresponding parent values

Scheduled Pinned Locked Moved C#
xmlworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    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
    
    G 1 Reply Last reply
    0
    • V Vimalsoft Pty Ltd

      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
      
      G Offline
      G Offline
      Gopal S
      wrote on last edited by
      #2

      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

      V 1 Reply Last reply
      0
      • G Gopal S

        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

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        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/

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups