多条件查询,高手请指教(50分)

  • 主题发起人 happyfly051
  • 开始时间
H

happyfly051

Unregistered / Unconfirmed
GUEST, unregistred user!
初学者的我执行下面的代码会出错,好像是SQL语句没有执行,不知道为什么,请各位高手指教

with Unit1.Form1.qry1 do
begin
Close;
SQL.Clear;
SQL.Add('Select 姓名,手机,分组 from [Leaf] where' +'(' + Trim(cbb1.Text) + '= :b'+')'+
'and '+'('+ Trim(cbb2.Text) + '= :d'+')');
Parameters.ParamByName('b').Value := edt1.Text;
Parameters.ParamByName('d').Value := edt2.Text;
Open;

if not IsEmpty then
begin
grp2.Caption := '查询结果:共('+ IntToStr(qry1.RecordCount)+'条)记录';
end else
begin
grp2.Caption := '查询结果:共(0条)记录';
end;
end
 
with Unit1.Form1.qry1 do
begin
Close;
SQL.Clear;
SQL.Add('Select 姓名,手机,分组 from [Leaf] where' +'(' + Trim(cbb1.Text) + '= '+#39+edt1.Text+#39+')'+
'and '+'('+ Trim(cbb2.Text) + '= '+#39+edt2.Text+#39+')');
Open;

if not IsEmpty then
begin
grp2.Caption := '查询结果:共('+ IntToStr(qry1.RecordCount)+'条)记录';
end else
begin
grp2.Caption := '查询结果:共(0条)记录';
end;
end
 
呵呵,不好意思,是我搞错了,程序里面的qry1和上面的Unit1.Form1.qry1不是同一个组件,所以会出错,不过分还是给你了,谢谢支持,以后我可不能这么粗心了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
715
import
I
D
回复
0
查看
743
DelphiTeacher的专栏
D
顶部