I am generating a report, but the problem is even though I’ve supplied credentials, when the form containing the CrystalReport opens up, it still asks me for them, and the worst part is, I don’t enter any thing in there, and just click finish, and it loads the report. So, if there is no need for credentials (or whatever) why is it asking me?
Here’s 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 pop ups

And, when this comes up, I don’t enter anything! That’s right! I just click finish and it loads the report perfectly! So, if it doesn’t needs anything, why the hel* is it asking me for a login?
We have lots of problems when we came to connect a crystal report to a different database to the one it was designed / created against. We ended up creating the following function to set it up correctly. It recursively sets the connection on all report tables and sub reports.
Also I seem to remember we had problems if the report was designed with Integrated Windows Authentications, and run with a simple username and password. So we always made sure we designed the reports with a simple username and password connection to the database.