Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Data Relation Creation

I found the following example of creating a Data Relation. I get the error DataSet1 is not declared
What additional code do I need

http://msdn.microsoft.com/en-us/library/system.data.datarelation(v=vs.110).aspx

    Private Sub CreateRelation()
        ' Get the DataColumn objects from two DataTable objects  
        ' in a DataSet. Code to get the DataSet not shown here.
        Dim parentColumn As DataColumn = _
            DataSet1.Tables("Customers").Columns("CustID")
        Dim childColumn As DataColumn = DataSet1.Tables( _
            "Orders").Columns("CustID")

        ' Create DataRelation.
        Dim relCustOrder As DataRelation
        relCustOrder = New DataRelation( _
            "CustomersOrders", parentColumn, childColumn)

        ' Add the relation to the DataSet.
        DataSet1.Relations.Add(relCustOrder)
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks
Not a problem murbro, glad to help.