procedure TForm1.Button4Click(Sender: TObject);begin
adoquery2.SQL.Clear;
adoquery2.Close;
adoquery2.sql.Text:=('select * from 表 where 字段1=:V or 字段2 =:v');
adoquery2.parameters.parambyname('V').value :=edit3.Text;
adoquery2.Open;
end;end.
只有字段1起作用
写法是不是和VB什么的不一样呢?

解决方案 »

  1.   

    procedure TForm1.Button4Click(Sender: TObject); 
    begin
    adoquery2.Close; 
    adoquery2.SQL.Clear; 
    adoquery2.sql.add( 'select * from 表 where 字段1=:V or 字段2 =:v '); 
    adoquery2.parameters.parambyname( 'V ').value :=edit3.Text; 
    adoquery2.Open; 
    end;
    end.
    sql语句没什么问题。。
      

  2.   

    SQL语句本身语法没什么问题,但不知道Lz要实现什么功能?
      

  3.   

    加个括号吧
    procedure TForm1.Button4Click(Sender: TObject); 
    begin 
    adoquery2.SQL.Clear; 
    adoquery2.Close; 
    adoquery2.sql.Text:=( 'select * from 表 where (字段1=:V) or (字段2 =:v) '); 
    adoquery2.parameters.parambyname( 'V ').value :=edit3.Text; 
    adoquery2.Open; 
    end;