我的这样试过,OK的:
procedure TdlgSelectBill.SelectBill;
begin
with M do
begin
SQL.Clear;
SQL.Add('SELECT ID, Code, BillDate, Amount, OperatorID, EmpID, Closed, Memo');
SQL.Add(' FROM ' + sTableName);
//无论如何,都要查询单据号码
SQL.Add(' WHERE Code LIKE :Code');
SQL.Add(' AND (BillDate BETWEEN :StartDate AND :EndDate)');
Parameters[0].Value := TRIM(edtCode.Text) + '%';
Parameters[1].Value := FormatDateTime('yyyy/mm/dd', StartDate.Date);
Parameters[2].Value := FormatDateTime('yyyy/mm/dd', EndDate.Date);
case rgClosed.ItemIndex of
0, 1:
begin
SQL.Add(' AND (Closed = :Closed)');
Parameters[3].Value := rgClosed.ItemIndex;
end;
end;
SQL.Add('ORDER BY BillDate DESC');
Open;
Caption := '单据查询结果: 共有 ' + IntToStr(RecordCount) + ' 条';
end;//with M do
end;
懒得修改了,就整个贴上来,你只要参考关键部份就行了.