if combobox3.Text='按住户姓查' then
  begin
    query1.Close;
    query1.SQL.clear;
    query1.SQL.add('select * from fzwj.dbf where zh like zhxing%');
    query1.Prepare;
    query1.ParamByName('zhxing').AsString:=edit4.Text;//给SQL变量赋值
    query1.Open;
    query1.Active:=true;
  end;
(注:“zh”是表fzwj.dbf中的字段,“zhxing”是String类的局部变量)
这样写程序执行为何得不到预期结果?错在哪?

解决方案 »

  1.   

    if combobox3.Text='按住户姓查' then
      begin
        query1.Close;
        query1.SQL.clear;
        query1.SQL.add('select * from fzwj.dbf where zh like :zhxing');
        query1.Prepare;
        query1.ParamByName('zhxing').AsString:=Trim(edit4.Text) + '%';//给SQL变量赋值
        query1.Open;  //Open和下面的True相当
    //    query1.Active:=true;
      end;
      

  2.   

    query1.Open;  //Open和下面的True相当 用一个就好了
    //    query1.Active:=true;