ComponentOne True DataControl 8.0
Tutorial 9 - Query Mode in TDataLite (part 2)

This tutorial is the second part of the lesson begun in Tutorial 10. It demonstrates another option that you have with TDataLite Query Mode: you will create a TDataLite control and data-bound controls intended solely for entering queries. Query results will be displayed in a separate DataGrid unrelated to the TDataLite control. Also, you will learn how to specify more complex query conditions, such as ranges, etc.

  1. Start a new project.

  2. Place the following controls on the form (Form1) as shown in the figure: an ADODC control (Adodc1), a TDataLite control (TDataLite1), a DataGrid control (DataGrid1), seven TextBox controls (Text1 to 7), seven labels (Label1 to 7) and a button (Command1).

  3. Set properties as follows:

    Example Title
    Copy Code
    Adodc1.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDBGDemo.mdb
    
    Adodc1.CommandType   2 – adCmdTable
    
    Adodc1.RecordSource  Orders
    
    TDataLite1.DataSource      Adodc1
    
    TDataLite1.QueryMode True
    
    TDataLite1.EOFAction adDoAddNew
    
    Adodc2.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDBGDemo.mdb
    
    Adodc2.CommandType   2 – adCmdTable
    
    Adodc2.RecordSource  Orders
    
    DataGrid1.DataSource Adodc2
    
  4. Open the property pages for TDataLite1, 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 TDataLite1, 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 TDataLite1, 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

    TDataLite1

    Text1.DataField

    OrderID

    Text2.DataSource

    TDataLite1

    Text2.DataField

    CustomerID

    Text3.DataSource

    TDataLite1

    Text3.DataField

    OrderDateFrom

    Text4.DataSource

    TDataLite1

    Text4.DataField

    OrderDateTo

    Text5.DataSource

    TDataLite1

    Text5.DataField

    ShipName

    Text6.DataSource

    TDataLite1

    Text6.DataField

    RequiredDateFrom

    Text7.DataSource

    TDataLite1

    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()
    
    Adodc2.Recordset.Filter = TDataLite1.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 8. We just want you to notice the following:

 

 


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

Product Support Forum  |  Documentation Feedback