function getaccessstr(databasename:string;password:string;accessVer:string='access2003'):string;
begin
if accessVer='access2003' then
begin
if password='no' then
result:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+databasename+';Persist Security Info=False'
else
result:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+databasename+';Persist Security Info=False;jet oledb:database password='+password;
end
else
if accessVer='access2007' then
begin
if password='no' then
Result := 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source='+databasename+';Persist Security Info=False'
else
result := 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source='+databasename+';Persist Security Info=False;jet oledb:database password='+password;
end;
end;
Microsoft.Jet.OLEDB.4.0,只能驱动access2003及以下版本的数据库,WINDOWS默认已经安装了该驱动。
Microsoft.ACE.OLEDB.12.0,可驱动所有版本的ACCESS数据库,WINDOWS默认没有安装该驱动。