Skip to main content

SqlDataSource.ValidateCustomSqlQuery Event

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

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v23.2.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

public event ValidateCustomSqlQueryEventHandler ValidateCustomSqlQuery

Event Data

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

Property Description
CustomSqlQuery Gets a custom SQL query being validated.
ExceptionMessage Gets or sets the exception message returned after validation of the custom SQL query.
Valid Gets or sets whether or not the current SQL query is valid.

Remarks

The ValidateCustomSqlQuery event is raised each time the custom SQL query (CustomSqlQuery), which is used to select data, needs to be validated. The ValidateCustomSqlQuery event is raised in the following cases.

The ValidateCustomSqlQueryEventArgs.CustomSqlQuery property returns the SQL query being validated. 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 ValidateCustomSqlQueryEventArgs.Valid property is set to false. The ValidateCustomSqlQueryEventArgs.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 ValidateCustomSqlQueryEventArgs.Valid flag and corresponding ValidateCustomSqlQueryEventArgs.ExceptionMessage message.

Important

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

To validate custom SQL for all queries created in an End-User Report Designer for WinForms, handle the SqlDataSource.ValidateCustomSqlQueryGlobal event.

See Also