我已经用了相对路径,试了5,6台电脑,只有1台出错,出错那台只装了2000专业版和office
ExePath:=ExtractFilePath(Application.ExeName);
try
ADOConnection.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'
+'User ID=Admin;'
+'Data Source='+ExePath+'MyDB.mdb;'
+'Mode=ReadWrite;'
+'Extended Properties="";'
+'Jet OLEDB:System database="";'
+'Jet OLEDB:Registry Path="";'
+'Jet OLEDB
atabase Password="'+pwd+'";'
+'Jet OLEDB:Engine Type=5;'
+'Jet OLEDB
atabase Locking Mode=0;'
+'Jet OLEDB:Global Partial Bulk Ops=2;'
+'Jet OLEDB:Global Bulk Transactions=1;'
+'Jet OLEDB:New Database Password="";'
+'Jet OLEDB:Create System Database=False;'
+'Jet OLEDB:Encrypt Database=False;'
+'Jet OLEDB
on'+#39+'t Copy Locale on Compact=False;'
+'Jet OLEDB:Compact Without Replica Repair=False;'
+'Jet OLEDB:SFP=False';
ADOConnection.Connected:=True;
if not ADOConnection.Connected then
begin
Application.MessageBox('连接数据库失败!','出错提示',MB_ICONERROR);
Exit;
end;
except
Application.MessageBox('连接数据库失败!','出错提示',MB_ICONERROR);
end;