笨
笨猪
Unregistered / Unconfirmed
GUEST, unregistred user!
我用adoquery将数据库表xx中的所有数据导出到一个文件中,代码如下:
var
f:Textfile;
str:string;
i,k:integer;
database:string;
begin
with datamodule2.ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select * from xx');
open;
end;
if savedialog1.Execute then
begin
assignfile(f,savedialog1.FileName);
rewrite(f);
str:=inttostr(datamodule2.ADOQuery2.RecordCount);
writeln(f,str);//写入记录个数
str:='';
str:=inttostr(datamodule2.ADOQuery2.FieldCount);
writeln(f,str);//写入字段个数
str:='';
while not datamodule2.ADOQuery2.Eof do
begin
for i:=0 to datamodule2.ADOQuery2.FieldCount-1 do
begin
str:=datamodule2.ADOQuery2.Fields.AsString;
writeln(f,str);
end;
datamodule2.ADOQuery2.Next;
end;
closefile(f);
end
end;
现在问题是:如何将这个导出的文件数据导入到对应的数据库表中??????
var
f:Textfile;
str:string;
i,k:integer;
database:string;
begin
with datamodule2.ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select * from xx');
open;
end;
if savedialog1.Execute then
begin
assignfile(f,savedialog1.FileName);
rewrite(f);
str:=inttostr(datamodule2.ADOQuery2.RecordCount);
writeln(f,str);//写入记录个数
str:='';
str:=inttostr(datamodule2.ADOQuery2.FieldCount);
writeln(f,str);//写入字段个数
str:='';
while not datamodule2.ADOQuery2.Eof do
begin
for i:=0 to datamodule2.ADOQuery2.FieldCount-1 do
begin
str:=datamodule2.ADOQuery2.Fields.AsString;
writeln(f,str);
end;
datamodule2.ADOQuery2.Next;
end;
closefile(f);
end
end;
现在问题是:如何将这个导出的文件数据导入到对应的数据库表中??????