Viewing criteria before its applied
Hi All
I'm assigning criteria to a report below. I get an access violation on the EMP_CODE line. The value is ok, = 2.
So I decided I needed to see the sql before its applied, however it seems to add it live using - lSQL.AddCriteriaField.
Is there a way to generate the criteria, view it, then apply it ? I can't get the showmessage to run because its already failed on the previous line.
Thanks
Andy
lDataModule := daGetDataModule(ppReport1);
lQueryDataView := TdaQueryDataView(lDataModule.DataViews[0]);
lTbl := lQueryDataView.SQL.GetTableForSQLAlias('JOB');
lCriteria := lSQL.AddCriteriaField(lTbl, 'JOBSTART', dacoGreaterThanOrEqualTo, QuotedStr(FormatDateTime('dd/mm/yyyy 00:00:00', dtDateFrom.Date)));
lCriteria := lSQL.AddCriteriaField(lTbl, 'JOBSTART', dacoLessThanOrEqualTo, QuotedStr(FormatDateTime('dd/mm/yyyy 23:59:59', dtDateTo.Date)));
//showmessage(strEngineerNo);
lCriteria := lSQL.AddCriteriaField(lTbl, 'EMP_CODE', dacoEqual, strEngineerNo);
showmessage(lSQL.SqlText.Text );
I'm assigning criteria to a report below. I get an access violation on the EMP_CODE line. The value is ok, = 2.
So I decided I needed to see the sql before its applied, however it seems to add it live using - lSQL.AddCriteriaField.
Is there a way to generate the criteria, view it, then apply it ? I can't get the showmessage to run because its already failed on the previous line.
Thanks
Andy
lDataModule := daGetDataModule(ppReport1);
lQueryDataView := TdaQueryDataView(lDataModule.DataViews[0]);
lTbl := lQueryDataView.SQL.GetTableForSQLAlias('JOB');
lCriteria := lSQL.AddCriteriaField(lTbl, 'JOBSTART', dacoGreaterThanOrEqualTo, QuotedStr(FormatDateTime('dd/mm/yyyy 00:00:00', dtDateFrom.Date)));
lCriteria := lSQL.AddCriteriaField(lTbl, 'JOBSTART', dacoLessThanOrEqualTo, QuotedStr(FormatDateTime('dd/mm/yyyy 23:59:59', dtDateTo.Date)));
//showmessage(strEngineerNo);
lCriteria := lSQL.AddCriteriaField(lTbl, 'EMP_CODE', dacoEqual, strEngineerNo);
showmessage(lSQL.SqlText.Text );
Comments
There is no longer a need to use or manipulate the SQL object directly in ReportBuilder (DADE). The SQLBuilder class was created to simplify the process.
See the help topic for the TdaSQLBuilder class and its subclasses for code examples and documentation. Something like the following for your application:
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com