Delphi XE2 を使用しています。
テーブルのレコードを cxgrid に表示するデータベース ソフトウェア パッケージがあります。ユーザーがクリックするだけで、特定のレコードを使用して結果を検索できるフィルター ボタンを実装しました。現時点では、レコードの 1 つが選択されている場合にのみ機能します。複数のフィルター レコードが選択されている場合は気に入らず、次のエラーが表示されます....「構文エラーまたはアクセス違反: 近く」および'in...[and]'. 次のコードは、フィルター ボタンをクリックした時点で行っていることです。
どんな助けでも大歓迎です。
begin
with dmData.aQry do
begin
Close;
SQL.Clear;
SQL.Text:= ('select * from DBA.RECORDS');
if dbluCaseCategory.Text <> '' then SQL.Add('where category_type like :category_type');
if dbluSubCategory.Text <> '' then SQL.Add('and sub_cat_type like :sub_cat_type');
if dbluCustomer.Text <> '' then SQL.Add('and customer_name like :customer_name');
if dbluUsername.Text <> '' then SQL.Add('and created_by_user like :created_by_user');
if cxStartDateEdit.Text <> '' then SQL.Add('and logged_dt like :logged_dt');
if dbluCaseCategory.Text <> '' then ParamByName('category_type').Value := dbluCaseCategory.Text +'%';
if dbluSubCategory.Text <> '' then ParamByName('sub_cat_type').Value := dbluSubCategory.Text +'%';
if dbluCustomer.Text <> '' then ParamByName('customer_name').Value := dbluCustomer.Text +'%';
if dbluUsername.Text <> '' then ParamByName('created_by_user').Value := dbluUsername.Text +'%';
if cxStartDateEdit.Text <> '' then ParamByName('logged_dt').Value := cxStartDateEdit.Text +'%';
Open;
end;
Close;
end;