vcl-dxbackend-dot-connectionstring-dot-sql-dot-tdxbackenddatabasesqlconnection-79374d23.md
Specifies if custom SQL queries are enabled for all TdxDashboard/TdxDashboardControl and TdxReport components in the application.
class property DefaultEnableCustomSql: Boolean read; write; default False;
| 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.
|
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.
The DefaultEnableCustomSql class property value affects the default value (bDefault) interpretation for the following properties:
TdxCustomDashboardControl.EnableCustomSqlSpecifies if custom SQL queries are enabled at the control level.TdxDashboard.EnableCustomSqlSpecifies if custom SQL queries are enabled for the loaded layout definition.TdxReport.EnableCustomSqlSpecifies if custom SQL queries are enabled at the component level.
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 Project → View 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.
#include <vcl.h>
#include "dxBackend.ConnectionString.SQL.hpp" // Declares the TdxBackendDatabaseSQLConnection component
#pragma hdrstop
#include <tchar.h>
//---------------------------------------------------------------------------------------
USEFORM("Unit1.cpp", MyForm);
//---------------------------------------------------------------------------------------
int WINMAIN _tWinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
TdxBackendDatabaseSQLConnection::DefaultEnableCustomSql = true; // Enables custom SQL queries globally
Application->Initialize();
Application->MainFromOnTaskBar = true;
Application->CreateForm(__classid(TMyForm), &MyForm);
Application->Run();
}
The DefaultEnableCustomSql property’s default value is False.
Footnotes
Layout property descriptions:See Also
TdxBackendDatabaseSQLConnection.ConnectionString Property
TdxBackendDatabaseSQLConnection Class