Delphi中使用ADO连接带密码的Access
var gDBConn:string;
try
self.ADOConnection1.Close;
//无密码连接方式 Password="";
//gDBConn:='Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=MyDB.mdb;Persist Security Info=True';
//有密码连接方式 Jet OLEDB:Database Password=delphi7;
gDBConn:='Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=123456;Data Source='+ExtractFilePath(application.ExeName)+'MyDB.mdb;Persist Security Info=True';
self.ADOConnection1.ConnectionString := gDBConn;
self.ADOConnection1.Open;
except
//raise;
self.ADOConnection1.Close;
self.ADOConnection1.Free;
application.MessageBox('不能连接到数据库!','提示信息',64);
application.Terminate;
end;