Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting Jet Database Password via c#


I'm using VS 2010 with CR 13. I have an access 2013 DB (accdb) which is encrypted with a password. the following code works if I remove the password but I can't find anyway to set the password via code:

public void SetCrystalLoginOLEDB(ReportDocument report)


            ConnectionInfo oConnectInfo = new ConnectionInfo();

            //string dbpath = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"\db\db.accdb");

            oConnectInfo.ServerName = Globals.DB;

            oConnectInfo.DatabaseName = "";

            oConnectInfo.UserID = "Admin";

            oConnectInfo.Password = "";

            //Set the logon credentials for all tables

            SetCrystalTablesLogin(oConnectInfo, report.Database.Tables);

            // Check for subreports

            foreach (CrystalDecisions.CrystalReports.Engine.Section oSection in report.ReportDefinition.Sections)


                foreach (CrystalDecisions.CrystalReports.Engine.ReportObject oRptObj in oSection.ReportObjects)


                    if (oRptObj.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)


                        // This is a subreport so set the logon credentials for this report's tables

                        CrystalDecisions.CrystalReports.Engine.SubreportObject oSubRptObj = oRptObj as CrystalDecisions.CrystalReports.Engine.SubreportObject;

                        // Open the subreport

                        CrystalDecisions.CrystalReports.Engine.ReportDocument oSubRpt = oSubRptObj.OpenSubreport(oSubRptObj.SubreportName);

                        SetCrystalTablesLogin(oConnectInfo, oSubRpt.Database.Tables);





            report.SetDatabaseLogon("Admin", "", Globals.DB, "");




        private void SetCrystalTablesLogin(CrystalDecisions.Shared.ConnectionInfo oConnectInfo, Tables oTables)


            foreach (CrystalDecisions.CrystalReports.Engine.Table oTable in oTables)


                CrystalDecisions.Shared.TableLogOnInfo oLogonInfo = oTable.LogOnInfo;

                oLogonInfo.ConnectionInfo = oConnectInfo;




I've tried setting the ConnectionInfo password, but I realise this isn't the same as the Jet password.

Any help much appreciated.



Former Member
Not what you were looking for? View more on this topic or Ask a question