Link to home
Start Free TrialLog in
Avatar of mahdiparak
mahdiparak

asked on

Change Access Databse Password

Hi Experts
How I can Change MSAccess Password In Delphi?
Avatar of sun4sunday
sun4sunday
Flag of India image

https://www.experts-exchange.com/questions/21080111/Change-access-password-with-Delphi.html

copying the solution

var
  db1, db2, fp1, fp2 : string;
begin
  db1:='c:\test\test.mdb';    // original flename
  db2:='c:\test\new.mdb';   // new filename
  fp1:='password';        //original file password
  fp2:='password';       //new file password
  try
    StatusBar.SimpleText:='Loading driver...';
    v := CreateOLEObject('JRO.JetEngine');
    try
      v.CompactDatabase('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + db1 +
                        ';Persist Security Info=False' + fp1,
                        'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + db2 +
                        'x; Jet OLEDB:Engine type=5'+ fp2);
    except
    on E:Exception do
           ShowMessage(E.Message);
    end;
  finally
    v := Unassigned;
    StatusBar.SimpleText:='Done.';
  end;
end;

sun4sunday
Avatar of TName
TName


Hi, are you using ADO? Try

ALTER DATABASE PASSWORD MyNewPassword MyOldPassword

e.g.:
ADOCommand1.CommandText := 'ALTER DATABASE PASSWORD MyNewPassword MyOldPassword';
ADOCommand1.Execute;

see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/acadvsql.asp

and you might want to have a look at
https://www.experts-exchange.com/questions/21900292/Protect-access-database-with-password.html

ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial