Delphi-Quellcode:
with ADODataSet_UserDepartment do
begin
Close;
if DepartmentID <> '' then
begin
CommandText := 'SELECT * FROM [User] WHERE Username LIKE :Username AND Forename LIKE :Forename AND Surname LIKE :Surname AND DepartmentID = :DepartmentID ORDER BY Username;';
Parameters.ParamByName('DepartmentID').Value := DepartmentID;
end
else CommandText := 'SELECT * FROM [User] WHERE Username LIKE :Username AND Forename LIKE :Forename AND Surname LIKE :Surname ORDER BY Username;';
Parameters.ParamByName('Username').Value :=
PrepareSearchString(Username) + '%';
Parameters.ParamByName('Forename').Value :=
PrepareSearchString(Forename) + '%';
Parameters.ParamByName('Surname').Value :=
PrepareSearchString(Surname) + '%';
Open;
end;
Access ist Krieg.
Ich benutze jetzt einfach zwei verschiedene Abfragen.