I am trying to make a simple crystal report viewer application and I cannot get the viewer to set the login info. Basically want I want to do is on the click of a button it should open a report. Pretty simple I thought but apparently not. Here's my code
private void button1_Click(object sender, EventArgs e)
{
ConnectionInfo connInfo = new ConnectionInfo();
connInfo.ServerName = "SERVER NAME";
connInfo.DatabaseName = "DATABASE NAME";
connInfo.UserID = "USERNAME";
connInfo.Password = "PASSWORD";
crystalReportViewer1.ReportSource = GetReportSource(connInfo);
crystalReportViewer1.RefreshReport();
}
private ReportDocument GetReportSource(ConnectionInfo connInfo)
{
ReportDocument document = new ReportDocument();
document.Load("REPORTPATH");
document.SetParameterValue(0, "04/02/2014");
document.SetParameterValue(1, "04/03/2014");
TableLogOnInfos logonInfos = new TableLogOnInfos();
TableLogOnInfo logonInfo = new TableLogOnInfo();
Tables tables;
tables = document.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
logonInfo = table.LogOnInfo;
logonInfo.ConnectionInfo = connInfo;
table.ApplyLogOnInfo(logonInfo);
}
return document;
}
The worst part is that this code works FINE on one of my computers but not the one I WANT it to work on. Again, this code totally compiles and works on one of my computers but not the other and I cannot figure out for the life of me why. God I hope someone can help.
When I run the program and click the button, it prompts me for the username and password, however when I enter it, it says "Login failed" another problem is that the "Database" field isn't populated on the login form even though it should be.