combit List & Label 29 - .NET Help
combit.Reporting.DataProviders Namespace / DbCommandSetDataProvider Class / AddRelation Method / AddRelation(String,String,String,String,String) Method

Name for the relation. May appear in the UI if multiple relations exist between the same two tables.

Name of the parent table.

Name of the child table.

Column name of the parent table. See remark section for composite key fields.

Column name of the child table. See remark section for composite key fields.



In This Topic
    AddRelation(String,String,String,String,String) Method
    In This Topic

    Adds a relation between two commands/tables.

    Syntax

    Parameters

    relationName

    Name for the relation. May appear in the UI if multiple relations exist between the same two tables.

    parentTableName

    Name of the parent table.

    childTableName

    Name of the child table.

    parentColumnName

    Column name of the parent table. See remark section for composite key fields.

    childColumnName

    Column name of the child table. See remark section for composite key fields.

    Remarks

    To support composite primary keys (the primary key of each table consists of two or more columns) for the relation, you can simple separate the individual column names by tab character '\t' for the parameters parentColumName and childColumnName.

    Example
    OleDbCommand command = new OleDbCommand("Select * from [Customers]", conn);
    OleDbCommand command2 = new OleDbCommand("Select * from [Orders]", conn);
    
    DbCommandSetDataProvider provider = new DbCommandSetDataProvider();
    provider.AddCommand(command, "Customers");
    provider.AddCommand(command2, "Orders");
    provider.AddRelation("Customers2Orders", "Customers", "Orders", "CustomerID", "CustomerID");
    
    LL.DataSource = provider;
    LL.Design();
    
    Dim command As New OleDbCommand("Select * from [Customers]", conn)
    Dim command2 As New OleDbCommand("Select * from [Orders]", conn)
    
    Dim provider As New DbCommandSetDataProvider()
    provider.AddCommand(command, "Customers")
    provider.AddCommand(command2, "Orders")
    provider.AddRelation("Customers2Orders", "Customers", "Orders", "CustomerID", "CustomerID")
    
    LL.DataSource = provider
    LL.Design()
    

    Requirements

    Platforms: Windows 10 (Version 21H2 - 23H2), Windows 11 (21H2 - 22H2), Windows Server 2016 - 2022
    .NET: .NET Framework 4.8, .NET 6, .NET 7, .NET 8

    See Also