1
12345
Unregistered / Unconfirmed
GUEST, unregistred user!
我想某一项添加记录,却总添到最后一项上?
如:
var
I,j,fieldp: Integer;
csv: textfile;
bfields,s,test: string;
begin
if cs22_ado.TableName='' then
cs22_ado.TableName:='cs22';
if cs22_ado.Active=false then
cs22_ado.Active:=true;
s := cdProc +'备份/' + copy(datetostr(date),4,2) + '/' + '财收22(' + copy(datetostr(date),4,2) +').csv';
assignfile(csv,s );
reset(csv);
readln(csv,bfields);
bfields:='';
cs22_ado.First ;
for I := 1 to (bpoint-1) do // bpoint-1 为要插入地积如的记录号
begin
cs22_ado.next;
end; // for
while not seekeof(csv) do
begin
readln(csv,bfields);
fieldp:=0;
j:=0;
showmessage(inttostr(cs22_ado.recno));
cs22_ado.Insert ;
for i := 1 to cs22_ado.FieldCount-1 do // Iterate
begin
if bfields=',' then
begin
test:=copy(bfields,(j+1),(i-j-1));
//showmessage(cs22_ado.FieldDefs.displayname);
cs22_ado.FieldByName(cs22_ado.FieldDefs[fieldp].displayname).asstring:=test;
j:=i;
//showmessage(test);
fieldp:=fieldP +1;
end;
end; // for
cs22_ado.post;
cs22_ado.next;
bfields:='';
end; // while // Iterate
showmessage('oo');
closefile(csv);//文件为csv文件(以 , 分割文件)
如:
var
I,j,fieldp: Integer;
csv: textfile;
bfields,s,test: string;
begin
if cs22_ado.TableName='' then
cs22_ado.TableName:='cs22';
if cs22_ado.Active=false then
cs22_ado.Active:=true;
s := cdProc +'备份/' + copy(datetostr(date),4,2) + '/' + '财收22(' + copy(datetostr(date),4,2) +').csv';
assignfile(csv,s );
reset(csv);
readln(csv,bfields);
bfields:='';
cs22_ado.First ;
for I := 1 to (bpoint-1) do // bpoint-1 为要插入地积如的记录号
begin
cs22_ado.next;
end; // for
while not seekeof(csv) do
begin
readln(csv,bfields);
fieldp:=0;
j:=0;
showmessage(inttostr(cs22_ado.recno));
cs22_ado.Insert ;
for i := 1 to cs22_ado.FieldCount-1 do // Iterate
begin
if bfields=',' then
begin
test:=copy(bfields,(j+1),(i-j-1));
//showmessage(cs22_ado.FieldDefs.displayname);
cs22_ado.FieldByName(cs22_ado.FieldDefs[fieldp].displayname).asstring:=test;
j:=i;
//showmessage(test);
fieldp:=fieldP +1;
end;
end; // for
cs22_ado.post;
cs22_ado.next;
bfields:='';
end; // while // Iterate
showmessage('oo');
closefile(csv);//文件为csv文件(以 , 分割文件)