Re: Assign username/password to access file
- From: Brian Bushay TeamB <BBushay@xxxxxxxxx>
- Date: Mon, 08 Oct 2007 22:00:32 -0500
Hello!
If I want to assign a username and a password to an existing accessfile, how
do I do this? Please code sample....
Your question isn't accurately phrased.
Access has two types of passwords. There is a database password the applies to
the Access datbase file. I assume this is what you mean by access file but
there is no user name associated with this password.
There are also use level security you can set for different objects that does
have a user and password.
Neither of these can be set with ADO.
You can set a database password by importing the JRO type library and using code
like this
uses JRO_TLB;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
engine: IJetEngine;
src, dst, path: WideString;
begin
path := ExtractFilePath(ParamStr(0));
//src is connection string to existing database with old password
src := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + path + 'test.mdb'
+
';Jet OLEDB:Database Password=oldpassword';
//dst is connection string to compacted db with new password
dst := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + path +
'compacted.mdb' +
';Jet OLEDB:Database Password=newpassword';
engine := CoJetEngine.Create();
engine.CompactDatabase(src, dst);
end;
--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.
- Follow-Ups:
- Re: Assign username/password to access file
- From: Paul Scott
- Re: Assign username/password to access file
- From: Mikael Lenfors
- Re: Assign username/password to access file
- References:
- Assign username/password to access file
- From: Mikael Lenfors
- Assign username/password to access file
- Prev by Date: TADOStoredProc
- Next by Date: Re: TADOStoredProc
- Previous by thread: Assign username/password to access file
- Next by thread: Re: Assign username/password to access file
- Index(es):