Skip to main content
All docs
V25.2
  • TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql Property

    Specifies if custom SQL queries are enabled for all TdxDashboard/TdxDashboardControl and TdxReport components in the application.

    Declaration

    class property DefaultEnableCustomSql: Boolean read; write; default False;

    Property Value

    Type Default Description
    Boolean False

    Specifies if TdxDashboard/TdxDashboardControl and TdxReport components can execute custom SQL queries specified in the current layout definition or in the UI:

    False

    Default. The bDefault EnableCustomSql property value is treated as bFalse. Refer to the following section for a complete list of affected properties: Affected Component Settings.

    Tip

    This is a strongly recommended option that ensures the safety of SQL queries.

    True

    The bDefault EnableCustomSql property value is treated as bTrue.

    Warning

    This option disables safety-related limitations on SQL queries at the application level. Ensure that you set all necessary user read/write permissions at the database level.

    Remarks

    A layout definition[1] for TdxDashboard/TdxDashboardControl and TdxReport components can include a SQL query if they connect to a relational database system using the TdxBackendDatabaseSQLConnection component.

    Important

    The Query Builder tool allows users to create only secure SELECT SQL queries. Custom SQL queries specified within the report or dashboard layout definition[1] are initially disabled and custom SQL query-related functionality is disabled in the UI.

    Enable custom SQL queries only if you ensure that you follow best practices and implement user read/write privileges at the database level using the tools available for your relational database management system.

    You can set the DefaultEnableCustomSql property to True at application startup to enable or disable custom SQL queries for all TdxDashboard/TdxDashboardControl and TdxReport components in the application. The EnableCustomSql property allows you to override the DefaultEnableCustomSql property at the level of individual components.

    Affected Component Settings

    The DefaultEnableCustomSql class property value affects the default value (bDefault) interpretation for the following properties:

    TdxCustomDashboardControl.EnableCustomSql
    Specifies if custom SQL queries are enabled at the control level.
    TdxDashboard.EnableCustomSql
    Specifies if custom SQL queries are enabled for the loaded layout definition.
    TdxReport.EnableCustomSql
    Specifies if custom SQL queries are enabled at the component level.

    Code Example: Enable Custom SQL Queries at Startup

    The code example demonstrated in this section changes the TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql class property value to True in the initialization section of the main application unit for all TdxDashboard/TdxDashboardControl and TdxReport components in the project.

    Open the Project Source to Edit the Main Function

    To open the main application unit of your project, you can use one of the following options:

    • Select ProjectView Source in the main menu of your RAD Studio IDE.
    • Select the target project in the Projects Window and press Ctrl + V (alternatively, you can display the context menu and select the View Source option).
    uses
      Forms,
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    begin
      TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql := True;  // Enables custom SQL queries globally
      Application.Initialize;
      Application.MainFormOnTaskBar := True;
      Application.CreateForm(TMyForm, MyForm);
      Application.Run;
    end.
    

    Default Value

    The DefaultEnableCustomSql property’s default value is False.

    Footnotes
    1. Use the following links to navigate to corresponding Layout property descriptions:

    See Also