I am using Visual Studio 2010 Ultimate Edition and I've installed the Beta 2 release of SAP Crystal Reports, version for Visual Studio 2010. Everything works fine but when I try to set the ReportSource property for the crystalReportViewer I can't find it. Is there any other way to bind a crystal report to CrystalReportViewer? This is my source:
var cryRpt = new ReportDocument();
cryRpt.Load("~/CrystalReports/DateToDateReport.rpt");
new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo;
var crConnectionInfo = new ConnectionInfo();
var crParameterDiscreteValue = new ParameterDiscreteValue {Value = dtpFromDate.Value};
ParameterFieldDefinitions crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
ParameterFieldDefinition crParameterFieldDefinition = crParameterFieldDefinitions["fromDate"];
ParameterValues crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crParameterDiscreteValue.Value = dtpToDate.Value;
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["toDate"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
crConnectionInfo.ServerName = "ServerName";
crConnectionInfo.DatabaseName = "Database";
crConnectionInfo.UserID = "Username";
crConnectionInfo.Password = "Password";
var crTables = cryRpt.Database.Tables;
foreach (Table crTable in crTables)
{
crtableLogoninfo = crTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crtableLogoninfo);
}
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();