cancel
Showing results for 
Search instead for 
Did you mean: 

Logon prompt appears when running report against a different database

Former Member
0 Kudos

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();

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

It might be possible that your reports are using the native client connection and the machines prompting for logon might havenot native client installed.

Install the native client on a machine and it would resolve your issue.

Hope that works!!

Regards

Amit

Former Member
0 Kudos

The reports are using SLQOLEDB and the computers already have the SQL native client installed. When i enter the details at the prompt the report loads and works fine, so i don't think it is a provider problem.

Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos
Former Member
0 Kudos

Thanks for the white paper, i have given it a quick read but as far as i can tell i am already doing the same code as seen in the example above.

All the reports are setup to use integrated security = false and this is not being changed by the program. It is sql authentication only.

Also the production database is on a different server instance and has a different database name and login credentials.

Edited by: Matthew Hare on Sep 17, 2008 4:06 PM

former_member183750
Active Contributor
0 Kudos

If the reports are using sql authentication, then you should not need the IntegratedSecurity line. see if commenting it out helps.

// connectioninfo.IntegratedSecurity = false;

Ludek

Former Member
0 Kudos

Removing that line has made no difference. I still get the database prompt

Former Member
0 Kudos

Is there any solution to this problem? i am currently having this issue with a report which uses a SQL VIEW as input table. Also, the user has dbowner rights