var
s,s1,s2,s3,s4:string;
value1,value2:string;
begin
s:='select * from house where 交易类型=买卖';
s1:='';
s2:='';
s3:='';
s4:='';
if combobox10.text<>'房屋用途' then
begin
s1:=combobox10.text;
s:=s+'and 房屋用途='''+s1+'''';
end;
if combobox11.text<>'层次' then
begin
s2:=combobox11.text;
s:=s+'and 房屋用途='''+s2+'''';
end;
if combobox12.text<>'房型' then
begin
s3:=combobox12.text;
value1:=copy(s3,0,1);
value2:=copy(s3,4,1);s:=s+'and 房型室='''+value1+'''and 房型厅='''+value2+''' ';
end;
if combobox13.text<>'房屋类型' then
begin
s4:=combobox13.text;
s:=s+'and 房屋类型='''+s4+'''';
end;
with datamodule3.ADOQuery1 do
begin
close;
sql.clear;
sql.add(s);
open;
end;
end;提示错误:    参数不足,期待是1;难道一定要用参数吗?
不用参数的话该怎么改?
各位帮帮忙啦

解决方案 »

  1.   

    我给你一点提示吧
    例如,用这样的组件.
    combobox1
    edit1
    中间不要再经过变量了.
    直接用'''+edit1.text+'''或'''+combobox1.item[i].text+'''
    可能会减少出错机会.这样用除了给自己找麻烦外,好像没有其他的作用.
    就这个程序而言,他可能把s1.s2.s3.s4中的中的一个当成参数了呀
    你试试照我说的方法,是不是可以呀
      

  2.   

    还是不行啊
    如果要参数的话
    这样是正解:
    var
    s,s1,s2,s3,s4:string;
    value1,value2:integer;
    begin
    s:='select * from house where 交易类型=:y and 数据性质=:z';
    s1:='';
    s2:='';
    s3:='';
    s4:='';
    if combobox10.text<>'房屋用途' then
    begins:=s+'and 房屋用途=:a';
    s1:=combobox10.text;
    end;
    if combobox11.text<>'层次' then
    begins:=s+'and 房屋用途=:b';
    s2:=combobox11.text;
    end;
    if combobox12.text<>'房型' then
    begin
    s:=s+'and 房型室=:c1 and 房型厅=:c2 ';
    s3:=combobox12.text;
    value1:=strtoint(copy(s3,0,1));
    value2:=strtoint(copy(s3,4,1));
    end;
    if combobox13.text<>'房屋类型' then
    begins:=s+'and 房屋类型=:d';
    s4:=combobox13.text;
    end;
    with datamodule3.ADOQuery1 do
    begin
    close;
    sql.clear;
    sql.add(s);
    paramByName('y').asstring:='买卖';
    paramByName('z').asstring:='详细数据';
    if s1<>'' then paramByName('a').asstring:=s1;
    if s2<>'' then paramByName('b').asstring:=s2;
    if s3<>'' then 
    paramByname('c1').asinteger:=value1;
    paramByname('c2').asinteger:=value2;
    if s4<>'' then paramByName('d').asstring:=s4;
    open;
    end;
    end;
    我有点不理解的是
    为什么将if s1<>'' then 
    if s2<>'' then 
    if s3<>'' then
    注销掉就无会出现
    paramter'a' not found
    而paramByName('y').asstring:='买卖';这句前却不用
    if s1<>'' then 这名与上面之间的关系怎样?