ComponentOne True DataControl 8.0
Tutorial 8 - Query Mode in TDataLite (part 1)

In this tutorial you will try a powerful feature of TDataLite: Query Mode.

Query Mode enables you to build ad-hoc query forms in a matter of minutes. It is an enhanced version of the Microsoft Access “Filter By Form,” and implements the paradigm known as “Query By Example."

In this tutorial, we will create a form that can function in two modes: query and results. The same TDataLite control and the same DataGrid are used to represent data in either mode.

Tutorial 9 will demonstrate another option that you have with TDataLite query mode: you will use a TDataLite control and data-bound controls that are intended solely for entering queries, results will be displayed, in a separate DataGrid without TDataLite.

  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) and two buttons (Command1, Command2).

  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  Products
    
    TDataLite1.DataSource      Adodc1
    
    TDataLite1.QueryMode True
    
    DataGrid1.DataSource TDataLite1
    
    DataGrid1.AllowAddNew      True
    
    DataGrid1.AllowDelete      True
    
    Command1.Caption     Query Mode
    
    Command2.Caption     Apply Query
    
  4. Open the TDataLite1 property pages. On the General page check the Query Mode check box in the Buttons group, which will make the Query button visible.

  5. On the Fields property page of TDataLite1, select the ProductName field. Select starts with in the Query Operation combo box.

  6. Add the following code to Command1:

    Example Title
    Copy Code
    Private Sub Command1_Click()
    
    TDataLite1.QueryMode = True
    
    End Sub
    
  7. Add the following code to Command2:

    Example Title
    Copy Code
    Private Sub Command2_Click()
    
    TDataLite 1.QueryMode = False
    
    End Sub
    
     
    

Run the Program and Observe the Following:

Close the program. You have successfully completed Tutorial 8.

 

 


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

Product Support Forum  |  Documentation Feedback