Skip to Content

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

Logon prompt appears when running report against a different database

I have a problem that when a report loads a logon prompt appears asking for username and password. I am using Visual Studio 2005 writing a C# winforms program using Crystal Reports XI. The reports are being loaded into the CrystalReportViewer.

The .rpt files were originally designed against our development database and we are changing the database details through the code to use the production database. The database and connections use sql authentication.

The logon prompt only appears on some users computers. The code we are using is below. Any ideas on how to stop the logon prompt appearing?

ConnectionInfo connectioninfo = new ConnectionInfo();
            connectioninfo.ServerName = str_ServerName;
            connectioninfo.DatabaseName = str_DatabaseName;
            connectioninfo.UserID = str_User;
            connectioninfo.Password = str_Password;
            connectioninfo.IntegratedSecurity = false;

            // Loop through main report and set connection info
            foreach (Table table in crep.ReportDoc.Database.Tables)
            {
                TableLogOnInfo logonInfo = table.LogOnInfo;
                logonInfo.ConnectionInfo = connectioninfo;
                table.ApplyLogOnInfo(logonInfo);
            }
            
            // Loop through subreports and set connection info
            foreach (ReportObject repobject in crep.ReportDoc.ReportDefinition.ReportObjects)
            {
                if (repobject.Kind == ReportObjectKind.SubreportObject)
                {

                    SubreportObject subrepobj = (SubreportObject)repobject;
                    ReportDocument subrepdoc = crep.ReportDoc.OpenSubreport(subrepobj.SubreportName);

                    foreach (Table table in subrepdoc.Database.Tables)
                    {
                        
                        TableLogOnInfo logonInfo = table.LogOnInfo;
                        logonInfo.ConnectionInfo = connectioninfo;

                        table.ApplyLogOnInfo(logonInfo);
                    }
                }
            }
   
            
            ReportViewer reportviewer = new ReportViewer(crep.ReportDoc);
            reportviewer.Show();

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