cancel
Showing results for 
Search instead for 
Did you mean: 

C# - Crystal Reports - Set Database and Report Source MDB

Former Member
0 Kudos

So I am trying to change the connection to params for a dynamic crystal report load. Basically making the rpt file a template and it can connect with whatever db location is specified in the app rather than what the developer selected when creating the rpt file. I have tried this but get no success

privatevoidViewReport(string pathToReport){
            crystalReportViewer1.ReportSource=GetReportSource(pathToReport);
            crystalReportViewer1.RefreshReport();}privateReportDocumentGetReportSource(string reportPath){ConnectionInfo crConnectionInfo =newConnectionInfo();ReportDocument document =newReportDocument();
            document.Load(reportPath); 
            crConnectionInfo.DatabaseName= dirToDB;
            crConnectionInfo.UserID="Admin";
            crConnectionInfo.Password="admin";TableLogOnInfos logonInfos =newTableLogOnInfos();TableLogOnInfo logonInfo =newTableLogOnInfo();Tables tables;
            tables = document.Database.Tables;foreach(CrystalDecisions.CrystalReports.Engine.Table table in tables){
                logonInfo = table.LogOnInfo;
                logonInfo.ConnectionInfo= crConnectionInfo;
                table.ApplyLogOnInfo(logonInfo);}return document;}

If I go to Crystal reports. Open the rpt file. Change the Connection details to my mdb file choosing (ole db as the connection protocol) and ONLY type in admin for the password. It connects with out a problem. I open the mdb file in Access. Type admin for password prompt and get let in.

So I guess my question do you have to set the ConnectionType and which parameters are needed for an MDB file that has a password.

Accepted Solutions (0)

Answers (0)