Back to Devexpress

Dashboard.ValidateCustomSqlQuery Event

dashboard-devexpress-dot-dashboardcommon-dot-dashboard-d788a784.md

latest5.6 KB
Original Source

Dashboard.ValidateCustomSqlQuery Event

Provides the capability to check the validity of the custom SQL query used to supply the dashboard with data.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public event ValidateDashboardCustomSqlQueryEventHandler ValidateCustomSqlQuery
vb
Public Event ValidateCustomSqlQuery As ValidateDashboardCustomSqlQueryEventHandler

Event Data

The ValidateCustomSqlQuery event's data class is ValidateDashboardCustomSqlQueryEventArgs. The following properties provide information specific to this event:

PropertyDescription
ConnectionNameGets the name of the connection to the data source containing a custom SQL query.
ConnectionParametersGets parameters used to establish a connection to the data source containing a custom SQL query.
CustomSqlQueryGets the custom SQL query that should be checked.
DataSourceComponentNameGets or sets the component name of the data source for which the event was raised.
DataSourceNameGets or sets the name of the data source for which the event was raised.
ExceptionMessageGets or sets the exception message returned after custom SQL query validation.
ValidGets or sets whether the current custom SQL query is valid.

Remarks

The ValidateCustomSqlQuery event is raised each time the custom SQL query, which is used to supply the dashboard with data, needs to be validated. This is true if the DashboardSqlDataSource is used as a dashboard data source and the CustomSqlQuery is used to select data. For instance, the ValidateCustomSqlQuery event is fired for each custom SQL query in the following cases.

  • The dashboard, which is supplied with data using a custom SQL query, is being loaded to the DashboardViewer.
  • Data in the data source is reloaded (for instance, using the DashboardViewer.ReloadData method).

Use the ValidateDashboardCustomSqlQueryEventArgs.ConnectionName/ValidateDashboardCustomSqlQueryEventArgs.ConnectionParameters properties to obtain the details of the connection to the SQL database. The ValidateDashboardCustomSqlQueryEventArgs.DataSourceComponentName event parameter returns the component name of the data source for which the event was raised. Finally, the ValidateDashboardCustomSqlQueryEventArgs.CustomSqlQuery event parameter returns the checked SQL query.

By default, a custom query used to obtain data from the SQL database should contain only SELECT statements. If the custom query contains not only SELECT statements, or the query is specified incorrectly, the ValidateDashboardCustomSqlQueryEventArgs.Valid property is set to false. The ValidateDashboardCustomSqlQueryEventArgs.ExceptionMessage property returns corresponding exception message.

If necessary, you can check the validity of the custom SQL query manually and override the value of the ValidateDashboardCustomSqlQueryEventArgs.Valid flag and corresponding ValidateDashboardCustomSqlQueryEventArgs.ExceptionMessage message.

Important

Note that the default validation is performed if the SqlDataSource.DisableCustomQueryValidation property is set to false.

See Also

Dashboard Class

Dashboard Members

DevExpress.DashboardCommon Namespace