Solved

VB.net Data Relation Creation

Posted on 2014-11-15
3
209 Views
Last Modified: 2014-11-15
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
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40444441
Hi murbro;

From the error it sounds like you have not created a DataSet object. In other words you need to instantiate a DataSet object and in that object add to the Tables collection the two tables Customers and Orders. Then to that same DataSet object add to the Relations collection the relationship you created to it. In your code you call this DataSet object DataSet1.
0
 

Author Closing Comment

by:murbro
ID: 40444530
Thanks
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40444533
Not a problem murbro, glad to help.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question