Solved

VB.net Data Relation Creation

Posted on 2014-11-15
3
204 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 62

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 62

Expert Comment

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

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now