ComponentOne True DataControl 8.0
Tutorial 16 - Query Mode (part 2)

This tutorial is the second part of the lesson begun in Tutorial 15. It demonstrates another option that you have with True DataControl Query Mode: you will create a TData control and data-bound controls intended solely for entering queries. Query results will be displayed with a separate TData control in a separate DataGrid.

  1. Start a new project.

  2. Place the following controls on the form (Form1) as shown in the figure: two TData controls (TData1, TData2), a DataGrid control (DataGrid1), seven TextBox controls (Text1 to 7), seven labels (Label1 to 7) and a button (Command1).

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

    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        Orders
    
    TData1.QueryMode           True
    
    TData1.EOFAction           adDoAddNew
    
    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
    
    TData2.QueryMode           False
    
    DataGrid1.DataSource       TData2
    
  4. Open the True DataControl property pages for TData1, and go to the Fields page. Delete all fields except the following: OrderID, CustomerID, ShipName (to delete a field, select it in the field list and press Del).

  5. In the Fields property page for TData1, select the ShipName field and change its QueryOperation property, select starts with in the Query Operation combo box.

  6. In the Fields property page for TData1, create four additional fields (by clicking the right mouse button and choosing New Field from the menu). For each of them select the data radio button, indicating that the field is a data field. For each of the four new fields, set its Name, DataSourceField and QueryOperation properties, typing in the Name edit box and selecting from the lists in the DataSource Field and Query Operationcombo boxes.

    Note: You must change Query Mode to 0 - Both or 1 - Query only for the Query Operation combo box to become available.


    Name:

    DataSource Field:

    Query Operation:

    OrderDateFrom

    OrderDate

    >=

    OrderDateTo

    OrderDate

    <=

    RequiredDateFrom

    RequiredDate

    >=

    RequiredDateTo

    RequiredDate

    <=

  7. Set properties of other controls as follows:

    Text1.DataSource

    TData1

    Text1.DataField

    OrderID

    Text2.DataSource

    TData1

    Text2.DataField

    CustomerID

    Text3.DataSource

    TData1

    Text3.DataField

    OrderDateFrom

    Text4.DataSource

    TData1

    Text4.DataField

    OrderDateTo

    Text5.DataSource

    TData1

    Text5.DataField

    ShipName

    Text6.DataSource

    TData1

    Text6.DataField

    RequiredDateFrom

    Text7.DataSource

    TData1

    Text7.DataField

    RequiredDateTo

    Set label and button captions according to the picture.

  8. Add the following code to Command1:

    Example Title
    Copy Code
    Private Sub Command1_Click()
    
    TData2.SourceRecordset.Filter = TData1.QueryFilter
    
    End Sub
    
                                    
    

Run the Program and Observe the Following:

We leave it to you to experiment with different queries and their results, as it was done in Tutorial 15. We just want you to notice the following:

Congratulations, you have completed all sixteen True DataControl tutorials! You are now ready to take full advantage of True DataControl in your applications.

 

 


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

Product Support Forum  |  Documentation Feedback