在4个combobox的OnChange事件中写:
var
s: string;
begin
with adodataset1 do
begin
s := ' and ';
if combobox1.itemindex>=0 then
s := 'FieldA='''+combobox1.text+'''';
if combobox2.itemindex>=0 ten
s := s + ' and FieldB='''+combobox2.text+'''';
if combobox3.itemindex>=0 then
s := s + ' and FieldC='''+combobox3.text+'''';
if combobox4.itemindex>=0 then
s := s + ' and FieldD='''+combobox4.text+'''';
if length(s)>5 then s := ' where '+copy(s, 6, $ffffffff) else s := '';
commandtext := 'select ShowField from Table '+s;
open;
if not isempty then
label1.caption := fields[0].asstring
else label1.caption := '不存在';
close;
end;
end;