locked
Implementing A Data Relation Using VB And MS Access RRS feed

  • Question

  • Hi:

    I have coded a data relation for a dataset with two datatables, "SE" and "CS". The "SE" Table is

    the parent and the "CS" is the child. The data relation does not work. The code to dispose of the 

    data relation does not work.

    Thanks .... John

    Create Data Relation

       dsPSB.Relations.Add("SE_CS", dsPSB.Tables("dtSE").Columns("SE_KEY"), dsPSB.Tables("dtCS").Columns("CS_KEY"))

    Create The "CS" BindingSource

      bsCS.DataSource = dsPSB 
      bsCS.DataMember = "SE_CS"
       

    Code To Dispose of the Data Relation when the child form closes.

       dsPSB.Relations.Remove("SE_CS")
       dsPSB.Tables.Remove("dtCS")




    Tuesday, February 12, 2019 5:51 PM

Answers

  • Hello,

    Here is a full blown code sample for master-details using MS-Access with VB.NET.

    The class CustomerOrders is were data is read and relations created for BindingSource components.

    Then in MainForm load event I hook up to several DataGridView controls.

    And here is another one I did last month

    https://github.com/karenpayneoregon/WorkingWithAccessDatabases/tree/master/MasterDetailRelation


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, February 12, 2019 7:15 PM