请问这段程序有何错误?(50分)

  • 主题发起人 主题发起人 moutocean
  • 开始时间 开始时间
M

moutocean

Unregistered / Unconfirmed
GUEST, unregistred user!
table1.Edit;
for i:=0 to table1.RecordCount -1do
begin
table1.FieldByName('score').value:=99
table1.next;
end;
table1.post;
 
table1.Edit;
Table1.First;
///here!!!
for i:=0 to table1.RecordCount -1do
begin
table1.FieldByName('score').value:=99
table1.next;
end;
//here!! Table1 has changed !do
NOT Post again!
or like this!
table1.Edit;
Table1.First;
while not Table1.EOFdo
begin
table1.FieldByName('score').value:=99
table1.next;
end;
 
在执行Table的Prior或Next过程时就会自动Post了,所以,你再次执行Post时就
会报错。
 
table1score.value:=99 ?
 
with Table1do
begin

First;

while not EOFdo

begin
Edit;
FieldByName('score').asfloat:=99;

post;
next;

end;
end;
 
应改成这样,因为TABLE.NEXT以后,TABLE的状况自动改变dsbrowse
不再是dsedit.另外,99后加;
for i:=0 to table1.RecordCount -1do
begin
table1.Edit;
table1.FieldByName('score').value:=99;
table1.next;
end;
table1.post;
 
table1.Edit;
for i:=0 to table1.RecordCount -1do
begin
table1.FieldByName('score').value:=99
table1.next;
end;
table1.Edit;
table1.post;
保证不出问题.
 
first: record in edit then
post
 
table1.active:=true;//或 table1.open;
table1.first;
for i:=0 to table1.RecordCount -1do
begin
table1.edit;
table1.FieldByName('score').value:=99;
table1.post;
table1.next;
end;
table1.active:=false;//或 table1.close;
这样最保险!
 
多人接受答案了。
 
后退
顶部