如何将dbf文件导入到access

2025-01-05 10:51:27
推荐回答(1个)
回答(1):

如下代码来自我自编的测试程序
procedure TForm1.Button1Click(Sender: TObject);
begin
try
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(Application.EXEName)+
'empty.mdb;Jet OLEDB:Database Password=';
ADOConnection1.Connected:=true;
except
showmessage('无法打开数据库,请:1.确认文件''zzglxt.mdb''在'+'下;2.运行该目录下的mdac_typ25.exe安装MDAC数据库驱动!!');
exit;
end;
// ADOConnection1.Execute('insert into szbmk select * from 6001szbmk in ''D:\dbf和acess相互转换'' ''dbase 5.0;'' order by bmh')
ADOConnection1.Execute('select * into szbmk from 6001szbmk in ''D:\dbf和acess相互转换'' ''dbase 5.0;'' order by bmh')

end;

procedure TForm1.Button2Click(Sender: TObject);
var
sql:string;
begin
try
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(Application.EXEName)+
'empty.mdb;Jet OLEDB:Database Password=';
ADOConnection1.Connected:=true;
except
showmessage('无法打开数据库,请运行该目录下的mdac_typ25.exe安装MDAC数据库驱动!!');
exit;
end;
sql := 'SELECT * INTO szbmk in ''D:\dbf和acess相互转换'' ''dbase 5.0;'' FROM szbmk';
ADOConnection1.Execute(sql);
end;

或是试试这个:
直接用BATCHMOVE控件,在BDE控件里的.