Removing A Data Relation In VB2019 RRS feed

  • Question

  • Hi:

    How would I dispose of the data relation so that I can dispose of the

    two datatables?

          'Create A DataRelation.
            Dim data_relation As New _
            DataRelation("SE_CS", dsPSB1.Tables("dtSE").Columns("SE_KEY"), dsPSB1.Tables("dtCS").Columns("CS_SE_KEY"))

        Remove A DataRelation Called "SE"CS"

         'Remove DataTables From The DataSet.


         'Dispose Of The Form.

    Wednesday, May 13, 2020 7:00 PM


  • Try this

    Remove any constraints e.g.

    ds.Tables("Your table name").Constraints.Remove("Constraint name goes here")

    Then remove the relationship

    If ds.Relations.Contains("MyRelation") Then
    End If
    Untested, done in notepad.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Wednesday, May 13, 2020 9:43 PM