V
visional
Unregistered / Unconfirmed
GUEST, unregistred user!
[]我想实现可按照两个条件同时满足查询 和 只要任意一个条件满足就能查询.
代码如下,但有错误,请高手帮忙解决.
procedure Tfview1.BitBtn2Click(Sender: TObject);
var
cc1,cc2,cc3,cc4 : string;
nn,nn1:integer;
begin
cc1 := combobox2.Text;
cc3 := edit2.Text;
Table1.First;
While (Not Table1.EOF) do
Begin
if (combobox1.Text:= 'and')then
begin
cc2 := Table1.FieldByName('dq').asString;
cc4 := Table1.FieldByName('xm').asString;
nn := CompareText (cc1, cc2);
nn1 := CompareText (cc3, cc4);
if (nn = 0) and (nn1=0) Then Break;
Table1.Next;
end;
End ;
else
if (combobox1.Text:='or') then
begin
cc2 := Table1.FieldByName('dq').asString;
cc4 := Table1.FieldByName('xm').asString;
nn := CompareText (cc1, cc2);
nn1 := CompareText (cc3, cc4);
if (nn = 0) or (nn1=0) Then Break;
Table1.Next;
end;
If (Table1.EOF) Then ShowMessage ('没有找到该记录。')
Else ShowMessage ('记录找到。');
end;
代码如下,但有错误,请高手帮忙解决.
procedure Tfview1.BitBtn2Click(Sender: TObject);
var
cc1,cc2,cc3,cc4 : string;
nn,nn1:integer;
begin
cc1 := combobox2.Text;
cc3 := edit2.Text;
Table1.First;
While (Not Table1.EOF) do
Begin
if (combobox1.Text:= 'and')then
begin
cc2 := Table1.FieldByName('dq').asString;
cc4 := Table1.FieldByName('xm').asString;
nn := CompareText (cc1, cc2);
nn1 := CompareText (cc3, cc4);
if (nn = 0) and (nn1=0) Then Break;
Table1.Next;
end;
End ;
else
if (combobox1.Text:='or') then
begin
cc2 := Table1.FieldByName('dq').asString;
cc4 := Table1.FieldByName('xm').asString;
nn := CompareText (cc1, cc2);
nn1 := CompareText (cc3, cc4);
if (nn = 0) or (nn1=0) Then Break;
Table1.Next;
end;
If (Table1.EOF) Then ShowMessage ('没有找到该记录。')
Else ShowMessage ('记录找到。');
end;