Crystal Reports, why does it request a login for the database even after I have provided the details?

I am creating a report, but the problem is that I provided the credentials when the form containing CrystalReport opens, it still asks me about them, and the worst part is I won’t enter anything there, and just click “Finish” and it downloads a report. So, if there is no need for credentials (or something else), why does this ask me?

Here is the code

private void MainReport_Load(object sender, EventArgs e) { var constr = string.Empty; constr = Application.StartupPath; if (Generate.bForProjects) constr = Path.Combine(constr, @"Reports\Projects.rpt"); else constr = Path.Combine(constr, @"Reports\Other.rpt"); var myConInfo = new CrystalDecisions.Shared.TableLogOnInfo(); reportDocument1.Load(constr); myConInfo.ConnectionInfo.DatabaseName = "ProjectData.mdb"; myConInfo.ConnectionInfo.ServerName = Application.StartupPath + @"\Data\ProjectData.mdb"; myConInfo.ConnectionInfo.Password = ""; myConInfo.ConnectionInfo.UserID = ""; reportDocument1.Database.Tables[0].ApplyLogOnInfo(myConInfo); reportDocument1.Refresh(); crystalReportViewer1.ReportSource = reportDocument1; crystalReportViewer1.Width = this.Width - 50; crystalReportViewer1.Height = this.Height - 100; } 

When the form loads, this screen appears.

enter image description here

And when that happens, I won’t enter anything! This is true! I just click Finish and it loads the report perfectly! So, if it doesn’t require anything, why does hel * ask me for a login?

+4
source share
3 answers

We have a lot of problems when we came to link the crystal report with another database to the one that it was designed / created against. As a result, we created the following function for proper configuration. It recursively establishes a join in all report tables and auxiliary reports.

In addition, I seem to remember that we had problems if the report was designed using integrated Windows authentication and started with a simple username and password. Therefore, we always made sure that we developed reports with a simple connection of the username and password to the database.

 private static void SetConnection(ReportDocument report, string databaseName, string serverName, string userName, string password) { foreach (Table table in report.Database.Tables) { if (table.Name != "Command") { SetTableConnectionInfo(table, databaseName, serverName, userName, password); } } foreach (ReportObject obj in report.ReportDefinition.ReportObjects) { if (obj.Kind != ReportObjectKind.SubreportObject) { return; } var subReport = (SubreportObject)obj; var subReportDocument = report.OpenSubreport(subReport.SubreportName); SetConnection(subReportDocument, databaseName, serverName, userName, password); } } private static void SetTableConnectionInfo(Table table, string databaseName, string serverName, string userName, string password) { // Get the ConnectionInfo Object. var logOnInfo = table.LogOnInfo; var connectionInfo = logOnInfo.ConnectionInfo; // Set the Connection parameters. connectionInfo.DatabaseName = databaseName; connectionInfo.ServerName = serverName; connectionInfo.Password = password; connectionInfo.UserID = userName; table.ApplyLogOnInfo(logOnInfo); if (!table.TestConnectivity()) { throw new ApplicationException(Resource.UnableToConnectCrystalReportToDatabase); } table.Location = Database + "." + "dbo" + "." + table.Location; } 
+2
source

Just create a report object and add the link below rptobj - a crystalreport object, and setdatabaselogin is a method that takes a user ID and password as a parameter.

rptobj.setdatabaselogon(userid,password)

+1
source

It appears only when your DataSet or DataTable is empty. So make sure it has data.

0
source

All Articles