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.   

    你同过Showmessage(s)显示一下s,看看是不是正确的SQL.
      

  2.   

    在Add之前用Showmessage(s)把你的sql语句显示出来看看是否合适
      

  3.   

    在Add之前用Showmessage(s)查看sql语句是否正确
      

  4.   

    'select * from house where 交易类型=买卖';
    s1:='';
    s2:='';
    s3:='';
    s4:='';
    if combobox10.text<>'房屋用途' then
    begin
    s1:=combobox10.text;
    s:=s+'and 房屋用途='''+s1+''''
    \\我觉得是你的语句有问题
    比如有些地方应该有个空格隔开的,你忽略了
    如:
    'select * from house where 交易类型=买卖'+'and 房屋用途='''+s1+''''
    就变为:
    select * from house where 交易类型=买卖and 房屋用途//
    很明显,“买卖”和“and”之间应该有个空格
    所以
    s:=s+'and 房屋用途='''+s1+''''应该是
    s:=s+' and 房屋用途='''+s1+''''