我想比较数据表中的记录,程序如下:
var a,b,c,d:boolean;
begin
with adoquery1 do
begin
first;
a:=fields[2].Value;
b:=fields[3].Value;
c:=fields[4].Value;
d:=fields[5].Value;
next;
while not eof do
begin
if(fields[2].Value=a)and(fields[3].Value=b)and(fields[4].Value=c)and(fields[5].Value<>d)
then showmessage('找到记录')
else next;
end;
end;
运行时,表中存在我要找的记录,却没有信息提示(showmessage).只是指针指向最后一条记录。请问问题在哪儿
var a,b,c,d:boolean;
begin
with adoquery1 do
begin
first;
a:=fields[2].Value;
b:=fields[3].Value;
c:=fields[4].Value;
d:=fields[5].Value;
next;
while not eof do
begin
if(fields[2].Value=a)and(fields[3].Value=b)and(fields[4].Value=c)and(fields[5].Value<>d)
then showmessage('找到记录')
else next;
end;
end;
运行时,表中存在我要找的记录,却没有信息提示(showmessage).只是指针指向最后一条记录。请问问题在哪儿
begin
with adoquery1 do
begin
first;
a:=fields[2].Value;
b:=fields[3].Value;
c:=fields[4].Value;
d:=fields[5].Value;
next;
while not eof do
begin
if(fields[2].Value=a)and(fields[3].Value=b)and(fields[4].Value=c)and(fields[5].Value<>d)
then
begin
showmessage('找到记录');
end
else next;
end;
end;
还是比第一条?
如果比第一条的话,while前面那个next去掉