现在我写的是这样的: with adodataset1 do begin open; for i:=1 to f1book1.lastrow do edit; for j:=1 to f1book1.lastcol do s:=f1book1.textrc[i,j]; filed[j-1].asstring:=s; updatebatch(); end; 可报错:违反主键约束。我的表格是有主键的,可这是修改,又不是append,怎么会这样?保证没修改主键的唯一性!
在你的代码中,adodataset1没有移动记录,总是修改第一条记录,当然违反主键约束了
这样看看 with adodataset1 do begin open; for i:=1 to f1book1.lastrow do edit; for j:=1 to f1book1.lastcol do s:=f1book1.textrc[i,j]; filed[j-1].asstring:=s; updatebatch(); Next; end;
with adodataset1 do
begin
open;
for i:=1 to f1book1.lastrow do
edit;
for j:=1 to f1book1.lastcol do
s:=f1book1.textrc[i,j];
filed[j-1].asstring:=s;
updatebatch();
end;
可报错:违反主键约束。我的表格是有主键的,可这是修改,又不是append,怎么会这样?保证没修改主键的唯一性!
with adodataset1 do
begin
open;
for i:=1 to f1book1.lastrow do
edit;
for j:=1 to f1book1.lastcol do
s:=f1book1.textrc[i,j];
filed[j-1].asstring:=s;
updatebatch();
Next;
end;