Building a DataRelation dynamically?

How do I build a DataRelation dynamically

The two tables in question are in memory and untyped. 
The tables and primary keys are built on the fly.
The tables are populated using sqlreader

Now I want to buld a DataRelation between these two tables.
My understanding of this process is like swiss cheese. Lots of holes!

Please help me get my arms around this.

tia,
Todd




Answer this question

Building a DataRelation dynamically?

  • BrianHenderson

    Sorry,
    Found the problem.
    Parentheses are not matched at Sum((

    VS didn't catch this one.
    The function works fine.

  • JoshZ

    Subject: Using ADO.NET aggregate functions

    Receiveing this error:
    Additional information: Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier.


    Based on this statement:

    ds.Tables.Item("ParentTable").Columns.Add("P5Sum", GetType(Decimal), "Sum((Child(myRelation).P5)")


    The "myRelation" DataRelation has five columns:
    Does this mean,  to use the aggregate function sum(), that the DataRelation can only have one comlumn  

    tia,
    Todd


  • gsutphin11

    you add the Relation object to the dataset( the container for the two tables) DataRelationCollection

    dataSet.Relations.Add("tab_1_tab_2", 
    dataSet.Tables["Tab1"].Columns["p_id"],
    dataSet.Tables["Tab2"].Columns["p_id"]);


    there several oveloads for the Add method

  • Building a DataRelation dynamically?