大哥:
我的代码如下,就是调试到table1.post出现提示“不能更新ID,字段不能更新“:
table1.DatabaseName:='yuan';
table1.TableName:='danxuan';
table1.Open;
table1.IndexFieldNames:='Knowledgepoint';
table1.First;
i:=1;
while (not table1.Eof) do
begin
if not(table1.State in [dsedit,dsInsert])then
table1.Edit;
table1.FieldByName('ID').Value:=i;
table1.Post;
i:=i+1;
table1.Next;
end;
table1.Close;
我的代码如下,就是调试到table1.post出现提示“不能更新ID,字段不能更新“:
table1.DatabaseName:='yuan';
table1.TableName:='danxuan';
table1.Open;
table1.IndexFieldNames:='Knowledgepoint';
table1.First;
i:=1;
while (not table1.Eof) do
begin
if not(table1.State in [dsedit,dsInsert])then
table1.Edit;
table1.FieldByName('ID').Value:=i;
table1.Post;
i:=i+1;
table1.Next;
end;
table1.Close;
改为,但是执行后,这个myid字段有些记录的这个myid字段还是空的
table1.DatabaseName:='yuan';
table1.TableName:='danxuan';
table1.Open;
table1.IndexFieldNames:='Knowledgepoint';
table1.First;
i:=1;
while (not table1.Eof) do
begin
if not(table1.State in [dsedit,dsInsert])then
table1.Edit;
table1.FieldByName('ID').Value:=i;
table1.Post;
i:=i+1;
table1.Next;
end;
table1.Close;
while (not table1.Eof) do
begin
table1.Edit;
table1.FieldByName('ID').Value:=i;
table1.Post;
i:=i+1;
table1.Next;
end;
会不好用?
table1.TableName:='danxuan';
table1.active:=true;//一定要有這一句
table1.Open;
table1.IndexFieldNames:='Knowledgepoint';
table1.First;
i:=1;
while (not table1.Eof) do
begin
if not(table1.State in [dsedit,dsInsert])then
table1.Edit;
table1.FieldByName('ID').Value:=i;
table1.Post;
i:=i+1;
table1.Next;
end;
table1.Close;