Quantcast
Channel: SCN : Unanswered Discussions - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 2556

Setting Jet Database Password via c#

$
0
0

Hi,

 

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.Refresh();            report.SetDatabaseLogon("Admin", "", Globals.DB, "");            report.VerifyDatabase();            report.Refresh();        }        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;                oTable.ApplyLogOnInfo(oLogonInfo);            }        }

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

 

Any help much appreciated.

 

Thanks,

Paul.


Viewing all articles
Browse latest Browse all 2556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>