Solved

VB.net Data Relation Creation

Posted on 2014-11-15
3
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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 to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

688 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