none
C#: How to add a row to a child table with a DataSet backing? RRS feed

  • Question

  • On the back end I am using XML files, xsd schemas a DataSet(dsThingPrograms) and DataTables. I have a parent ->child table relationship defined through the DataSet designer as such:

     

    things[RFID(pkey), name]
    programs[ID(pkey/autogen), name, path, thing_RFID(FK references things->RFID)]
    

     

    In my code I have:

     

    dsThingPrograms.things.AddthingsRow("lala"
    , "00ffe4"
    );
    dsThingPrograms.things.WriteXml("path\to\things.xml"
    , System.Data.XmlWriteMode.WriteSchema);
    

     

    which works fine. However the problem comes when I try to add a row to the Programs table. When I do:

     

    dsThingPrograms.programs.AddprogramsRow("someprog"
    , "some\path"
    , <???>);
    

     

    VS wants me to add a "dsThingPrograms.thingsRow parentthingsRowByFK_things_programs" where the <???> is. I've tried a bunch of things but I could not satisfy that requirement and can't even get the code to compile. What is supposed to go in there to satisfy the FK property?

    • Edited by Suan Yeo Tuesday, August 31, 2010 4:22 PM edited formatting
    • Moved by eryang Wednesday, September 1, 2010 3:42 AM Move to XML forum for better support. (From:.NET Base Class Library)
    • Moved by Allen ZhangMicrosoft employee Friday, September 10, 2010 10:28 AM Not XML question rather questions on DataSet. (From:XML and the .NET Framework)
    Tuesday, August 31, 2010 4:15 PM

All replies