为什么前三个查询条件一填就出错? procedure TFormserch.Button1Click(Sender: TObject); var i:integer; s,low,high:string; begin s:='select * from handset '; i:=0; if trim(edit1.Text)<>' then begin s:=s+'where type=''+trim(edit1.Text)+''; i:=i+1; end; if trim(edit2.Text)<>' then begin if i=0 then s:=s+'where name=''+trim(edit2.Text)+'' else s:=s+' and name=''+trim(edit2.Text)+''; i:=i+1; end; if trim(edit3.Text)<>' then begin if i=0 then s:=s+'where cash=''+trim(edit3.Text)+'' else s:=s+' and cash=''+trim(edit3.Text)+''; i:=i+1; end;
low:=formatDateTime('mm'/'dd'/'yyyy',DateTimePicker1.Date); high:=formatDateTime('mm'/'dd'/'yyyy',DateTimePicker2.Date); s:=s+'where '+'da<=''+high+'' and da>=''+low+'';
with query1 do begin close; query1.sql.Clear; query1.sql.Add(s); try query1.Open; except query1.execsql; end; end; end;