By default DevExpress XtraReports enduser report designer allows only creating SQL statements using Query Builder. Custom SQL statements are security risk and because of that they are not allowed by default. If you know what you are doing and want to use custom SQL statements then they can be enabled on Report Designer form. See closer documentation at DevExpress site.
What about situation where designer is creader in code like :
XtraReport report = = new XtraReport { DataSource = MyTable }; XRDesignRibbonForm designForm = = new XRDesignRibbonForm(); designForm.DesignMdiController.OpenReport(report); designForm.ShowDialog();
Obviously approach is same, but finding corresponding property might be a bit tricky. So here it is
designForm.DesignMdiController.DataSourceWizardSettings.SqlWizardSettings.EnableCustomSql = true;
And full code will look like this:
XtraReport report = = new XtraReport { DataSource = MyTable }; XRDesignRibbonForm designForm = = new XRDesignRibbonForm(); designForm.DesignMdiController.DataSourceWizardSettings.SqlWizardSettings.EnableCustomSql = true; designForm.DesignMdiController.OpenReport(report); designForm.ShowDialog();
In result Custom SQL will be enabled:
Important
For security reasons, enabling custom SQL editing is not recommended if your reporting application can be accessed by untrusted parties. Refer to the Database Security document for more information.