ComponentOne True DataControl 8.0
Tutorial 6 - A Common Example of a Master-Detail Relationship

The True DataControl model of the master-detail relationship is extremely extensive and flexible. It can be used to implement a variety of situations in application development that would otherwise need manual coding. Its diversity is, in fact, the focus of Tutorials 5, 6, 7, 8, 9, 13, and 14. The example by which it was introduced in the previous tutorial might not be recognized as a common case of what is usually called a "master-detail" or "one-to-many" relationship. This tutorial will furnish a more common example where the position in one data set determines data contained by another. In this example, three TData controls are connected to form a three-level master-detail chain.

  1. Start a new project.

  2. Place the following controls on the form (Form1) as shown in the figure: three TData controls (TData1 to 3) and three DataGrid controls (DataGrid1 to 3).

  3. Set properties as follows (you can use the DataSource property page to set TData data source properties, as described in Tutorial 3):

    Example Title
    Copy Code
    TData1.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDDEMO.MDB
    
    TData1.CommandType   2 – adCmdTable
    
    TData1.RecordSource  Customers
    
    DataGrid1.DataSource TData1
    
    TData2.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDDEMO.MDB
    
    TData2.CommandType   2 – adCmdTable
    
    TData2.RecordSource  Orders
    
    DataGrid2.DataSource TData2
    
    TData3.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDDEMO.MDB
    
    TData3.CommandType   2 – adCmdTable
    
    TData3.RecordSource  [Order Details]
    
    DataGrid3.DataSource TData3
    
  4. Open the True DataControl property pages for TData2. On the General page select TData1 in the Master combo box. On the True DataControl property pages for TData3, in the General page, select TData2 in the Master combo box.

  5. On the Fields page for TData2, select the CustomerID field. Click the right mouse button over the CustomerID field and select New Range Condition from the menu (alternatively, you can use the New button). An empty range condition for the CustomerID field appears with controls for entering the condition now visible in the right part of the page. Go to the Value Expression text box and type the following expression: TData1.CustomerID. This will create a CustomerID = TData1.CustomerID range condition for the CustomerID field.

  6. Now go to the TData3 property pages and create a range condition OrderID = TData2.OrderID for the OrderID field, following the same procedure as in the previous step.

Run the Program and Observe the Following:

Close the program. You have successfully completed Tutorial 6.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback