j:='provider=Microsoft.Jet.OLEDB.4.0;user ID=Admin;Data Source='
+ExtractFilePath(Application.ExeName)+'Database.mdb;'
+'Mode=Share Deny None;Extended Properties="";'
+'Jet OLEDB:System database="";'
+'Jet OLEDB:Registry Path="";'
+'Jet OLEDB:Database Password="123";' //设定密码为123
+'Jet OLEDB:Engine Type=5;'
+'Jet OLEDB:Database Locking Mode=1;'
+'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:Don'+''''+'t Copy Locale on Compact=False;'
+'Jet OLEDB:Compact Without Replica Repair=False;'
+'Jet OLEDB:SFP=False';
ADOConnection1.LoginPrompt:=false;
ADOConnection1.ConnectionString:=j;
简单点也可以这样:
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDatabase.mdb;Persist Security Info=False;Jet OLEDB:Database Password=密码';
ADOConnection1.Connected := True;