很容易。用ADOQUERY 取出ACCESS里面的内容。然后声明文件变量 var f:TextFile; begin AssignFile(f,filePath); ReWrite(f); ... ... for j:=1 to FieldCount-1 do //插入一条记录 begin str:=Trim(Fields[j].AsString); k:=length(trim(Str)); for i:=k+1 to Fields[j].DataSize-1 do begin Str:=Str+' '; end; Write(f,Str);//写入 end; Write(f,#13#10);//换行 ... ... CloseFile(f); end;
var
f:TextFile;
begin
AssignFile(f,filePath);
ReWrite(f);
...
...
for j:=1 to FieldCount-1 do //插入一条记录
begin
str:=Trim(Fields[j].AsString);
k:=length(trim(Str));
for i:=k+1 to Fields[j].DataSize-1 do
begin
Str:=Str+' ';
end;
Write(f,Str);//写入
end;
Write(f,#13#10);//换行
...
...
CloseFile(f);
end;
path,sql:string;
str_con:string;
begin
conn.Close ;
path:=extractfilepath(application.ExeName );
str_con:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + path + '\my.mdb;Persist Security Info=False;Jet OLEDB:Database Password=test;
conn.ConnectionString :=str_con;
try
conn.connected:=true;
showmessage('ok');
except
showmessage('error');
end;//生成TXT文本文件
Sql:='select * into [text;Database=' + path + '].test.txt' + ' from eu_onipot';
conn.Execute(sql);
showmessage('over txt');
path,sql:string;
str_con:string;
begin
conn.Close ;
path:=extractfilepath(application.ExeName );
str_con:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + path + '\my.mdb;Persist Security Info=False;Jet OLEDB:Database Password=test;
conn.ConnectionString :=str_con;
try
conn.connected:=true;
showmessage('ok');
except
showmessage('error');
end;//生成TXT文本文件
Sql:='select * into [text;Database=' + path + '].test.txt' + ' from eu_onipot';
conn.Execute(sql);
showmessage('over txt');
try
Close;
CommandText:=' select * from table ';
Open;
SaveToFile('c:\x.txt');
Close;
except
end;
f:textfile
i:integer
begin
while not adotable1.eof do
begin
//加入qqqeee(zipple) 的内容
end;
end;