0

I want to change my .mdb Database password by C# code. I am using following code for this but some error comes. So please help me.

IErrorInfo.GetDescription failed with E_FAIL(0x80004005). This error comes.

Code:

  OleDbConnection cnn1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Jet OLEDB:Database Password=" + pwd + ";Mode=Share Exclusive");
  OleDbCommand cmd1 = new OleDbCommand();
  cnn1.Open();
  cmd1.Connection = cnn1;


  string Query="ALTER DATABASE PASSWORD <newPassword> " + pwd + "";  

  cmd1.CommandText = Query;
  blnSuccess = cmd1.ExecuteNonQuery();

1 Answer 1

2

In the Last finally i got the answer of my Question.

Following code is help me for change the .mdb Database Password change by C# Code.

Add a reference to Microsoft DAO 3.6 Object Library

using DAO;

public void ChangePassword(string sDBPath, string sDBPasswordOld, string sDBPasswordNew)
{
     dao.DBEngine dbEngine;
     dao.Database db;
     db = dbEngine.OpenDatabase(sDBPath, true, false, ";PWD=" + sDBPasswordOld);
     db.NewPassword(sDBPasswordOld, sDBPasswordNew);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.