cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports Viewer - Sub reports failed login

Former Member
0 Kudos

Environment:

  • SAP Crystal Reports, version for Microsoft Visual Studio - 13.0.17.2096
  • .NET Framework 4.6.1
  • Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64)

 

I have inherited a handful of reports/code and am trying to get all of them running. 

The stand-alone reports seem to be working fine, but those with Sub Reports are failing.  By default the EnableDatabaseLogonPrompt property of the CrystalReportView object is true, so the user is prompted to enter DB information for reports containing sub reports, which I don't want. I set the property to 'false', so I could hopefully get some more insight as to what is going on. 

The message reads:

Logon failed. Error in File ServiceChange 22476_17668_{83F2F851-7777-445A-B5F1-2F8942D8B653}.rpt: Unable to connect: incorrect log on parameters.



I've read several articles and tried suggested solutions, but nothing seems to work.  Here is a snippet of the code that is setting the connection information.

/// The report document is loaded (specific code omitted)

var reportDocument = new ReportDocument();

reportDocument.Load(filePath);

ConnectionInfo connectionInfo = GetConnectionInfo();

SetDBLogonForReport(connectionInfo, reportDocument);

SetDBLogonForSubReports(connectionInfo, reportDocument);



private static ConnectionInfo GetConnectionInfo()

        {

            return new ConnectionInfo

            {

                ServerName = SystemConfiguration.Instance.GetProperty ( "ConnectionManager.DataSource" ),

                DatabaseName = SystemConfiguration.Instance.GetProperty ( "ConnectionManager.Catalog" ),

                IntegratedSecurity = true

            };

        }

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

        {

            Tables tables = reportDocument.Database.Tables;

            foreach (Table table in tables)

            {

                TableLogOnInfo tableLogonInfo = table.LogOnInfo;

                tableLogonInfo.ConnectionInfo = connectionInfo;

                table.ApplyLogOnInfo(tableLogonInfo);

            }

        }

private void SetDBLogonForSubReports(ConnectionInfo connectionInfo, ReportDocument reportDocument)

        {

            Sections sections = reportDocument.ReportDefinition.Sections;

            foreach (Section section in sections)

            {

                ReportObjects reportObjects = section.ReportObjects;

                foreach (ReportObject reportObject in reportObjects)

                {

                    if (reportObject.Kind == ReportObjectKind.SubreportObject)

                    {

                        var subreportObject = (SubreportObject) reportObject;

                        ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);

                        SetDBLogonForReport(connectionInfo, subReportDocument);

                    }

                }

            }

        }

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Search for KBA 2281780, there is a Parameter app attached to the Doc and see if that works.

How are you connecting ODBC or OLE DB?

Which DB client are you using?

Don

Answers (0)