首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

adoquery 多条件查询?解决方案

2012-02-17 
adoquery 多条件查询?procedure TForm1.Button4Click(Sender: TObject)beginadoquery2.SQL.Clearadoquer

adoquery 多条件查询?
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什么的不一样呢?


[解决办法]

Delphi(Pascal) code
procedure TForm1.Button4Click(Sender: TObject); beginadoquery2.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.
[解决办法]
加个括号吧
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; 

热点排行