Description


Contains an SQL query if the component was populated with data using the button with the "SQL query" action.


It also allows you to set your own SQL query that will be executed when the dbSQLExecute method is called.



Example


procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    // include the id field into SQL query, if the possibility to edit or delete records is necessary
    // include "$autoinc" into SQL query if a column with sequential numbering is required
    Form1.TableGrid1.dbSQL:='SELECT id, "$autoinc", lastname, firstname, salary FROM employees';


    //Form1.GridEmployees.dbParentTable := 'ParentTable'; // optionally
    //Form1.GridEmployees.dbParentTableId := 1; // optionally


    // optional, in case of complex SQL query, specify the main database table manually,
    // to which the id field specified in the SQL query in the dbSQL property will belong
    Form1.TableGrid1.dbGeneralTable := 'employees';  


    // specify header names for columns, separated by commas,
    // if it is necessary to hide a column in a component, specify the name delete_col, as a rule, it is useful to hide the id field

    Form1.TableGrid1.dbListFieldsNames :='delete_col,#,name2,name3,name4';
    Form1.TableGrid1.dbSQLExecute; // Execute an SQL query
end;