function GetWhere(Field, Condition, Param: string): string//请教这个函数(1分)

  • 主题发起人 主题发起人 pchddcat
  • 开始时间 开始时间
P

pchddcat

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
//zhu是表名,prive是字段,
function GetWhere(Field, Condition, Param: string): string;
begin
Result := '';
if Param = '' then
Exit;
if SameText(Field, 'prive') or SameText(Field, 'to_prive') then
Result := Format(' where %s %s %s', [Field, Condition, Param])
else
Result := Format(' where %s %s ''%s''', [Field, Condition, Param]);
end;

var
Where: string;
begin
Where := GetWhere(cmbField.Text, cmbCondition.Text, Trim(cmbParam.Text));
with ADOQuery1 do
begin
if Active then
Close;
SQL.Text := 'select * from zhu ' + Where;
Open;
First;
AdjustDBGrid(DBGrid1);
end;
end;
 
后退
顶部