procedure TForm1.dao1Click(Sender: TObject);
type
  Str = ARRAY [1..5] OF String;
var
  CarNum,UseDep,System,Proper,Insurer:String;
  i:Integer;
  S,F:Str;
  sql:String;
begin
  CarNum:=Edit1.Text;
  UseDep:=Edit2.Text;
  System:=ComboBox1.Text;
  Proper:=Edit3.Text;
  Insurer:=Edit4.Text;
   F[1]:='CarNum';
   F[2]:='UseDep';
   F[3]:='System';
   F[4]:='Property';
   F[5]:='Insurer';
   showmessage(F[1]);
   S[1]:=CarNum;
   S[2]:=UseDep;
   S[3]:=System;
   S[4]:=Proper;
   S[5]:=Insurer;
   sql:='Select * from lenovo.jbxx where 1>0 and 9>1';
  i:=1;
  for I :=1 to 5 do
  begin
    if S[i]='' then
    begin
    sql:=sql+'';
    end
    else
    begin
    sql:=sql+'and '+F[i]+' like '''+'%'+S[i]+'%'+''' ';  
                                           ';    end
 
  end;
  end;