W
wjhn
Unregistered / Unconfirmed
GUEST, unregistred user!
我用一个query和一个table来显示数据,我从query中取值和table中的所有记录对比,
当table中已有的这条记录时越过,
当table中没有时添加一条记录到table中,我用了两个while do 来作,
with query1 do
begin
first;
while not query1.eof do
begin
with table1 do
begin
first;
while not table1.eof do
begin
if copy(table1.fieldbyname('msgtext').asstring,3,4)=copy(query1.fieldbyname('mesg').asstring,1,4) then
break//退出循环
else
next;
end;
end;
table1.append;
table1.FieldByName ('amp').asdatetime:=query1.fieldbyname('sendtime').asdatetime;
table1.FieldByName ('ori').asstring:=query1.FieldByName ('msg').asstring
table1.FieldByName ('msg').asstring:='g';
table1.FieldByName ('text').asstring:=text1+text2+text3;
table1.post;
Next ;
end;
end;
这个循环运行后是会一直在最后添加记录,我不知道应怎样才能实现这种功能。
当table中已有的这条记录时越过,
当table中没有时添加一条记录到table中,我用了两个while do 来作,
with query1 do
begin
first;
while not query1.eof do
begin
with table1 do
begin
first;
while not table1.eof do
begin
if copy(table1.fieldbyname('msgtext').asstring,3,4)=copy(query1.fieldbyname('mesg').asstring,1,4) then
break//退出循环
else
next;
end;
end;
table1.append;
table1.FieldByName ('amp').asdatetime:=query1.fieldbyname('sendtime').asdatetime;
table1.FieldByName ('ori').asstring:=query1.FieldByName ('msg').asstring
table1.FieldByName ('msg').asstring:='g';
table1.FieldByName ('text').asstring:=text1+text2+text3;
table1.post;
Next ;
end;
end;
这个循环运行后是会一直在最后添加记录,我不知道应怎样才能实现这种功能。