My question is this: Has ANYONE on this planet been able to get the ASP .NET CR Viewer control to actually work?
Why does this editor NOT recognize End-of-line or CR characters or any whitespace??
I have developed a Crystal Reports "Viewer" web application in VS2008 using C#.
It's a simple app, in that it's a single page with a treeview control (containing the grouped names of the reports to which the user has access) and the CR Viewer control.
The report files live on a network share, and permissions to them is controlled via a SQL Server database, which, for each report, stores the UserID and Logion for the oracle database, as well as any required parameter values.
The reports themselves are all hititng an Oracle 10g database.
I managed to do this in a Windows desktop applcation using Visual Studio 2005 and VB .net, but now, upon trying to make this a web application in VS2008, I have completely failed. The application works when run locally, but when deployed to the web server, I experience database login prompts when I should not, (the dreaded "Report requires further information" message) even thought the setdatabaselogin has already been set. I have tried saving the reportdocument in viewstate and re-assigning the viewer Datasource property to it, that also fails. However, it only does it on some reports, and not others. (admittedly, the reports may have been created using different CR versions)
The viewer also displays data it should not be displaying when I attempt to scroll, when I do manage to get a report to run.
I am setting parameters dynamically at run time, whose values are stored in the SQL database.
Code Sample:
protected void ShowReport(int ReportID)
{
SQLDataPortal2005.Common sql = new SQLDataPortal2005.Common();
Hashtable outParms = new Hashtable();
string sAccess;
IDataReader dr;
CrystalDecisions.CrystalReports.Engine.ReportDocument rptDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
sAccess = p.Identity.Name;
int j = 0;
int i = -1;
if (!IsAdmin())
{
sql.ExecNonQuery("CrystalReports", outParms, "proc_CRM_Check_Permissions", sAccess, Convert.ToInt32(TreeView1.SelectedNode.Value));
if (outParms["@Allow"].ToString() != "True")
{
Response.Redirect("ErrorPage.aspx"); // redirect to error page
}
}
string sPath = System.Configuration.ConfigurationManager.AppSettings["WareHouse"].ToString();
sPath = sPath + TreeView1.SelectedNode.Text.Trim() + ".rpt";
rptDocument.Load(sPath);
dr = sql.GetDataReader("CrystalReports", "proc_CRM_Get_Report", Convert.ToInt32(TreeView1.SelectedNode.Value));
while (dr.Read() == true)
{
j += 1;
if (j < 2)
{
rptDocument.SetDatabaseLogon(dr["DB_Login"].ToString(), dr["DB_Pwd"].ToString(), "PLAW", "LAWDB", true);
pList = dr["ParmList"].ToString().Split(',');
}
}
dr.Close();
dr.Dispose();
if (pList.Length > 0 && pList[0].ToString().Trim() != "")
{
foreach (CrystalDecisions.Shared.ParameterField x in rptDocument.ParameterFields)
{
i++;
switch (x.ParameterValueType)
{
case CrystalDecisions.Shared.ParameterValueKind.BooleanParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToBoolean(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.CurrencyParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToDouble(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.DateParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.DateTimeParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.NumberParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToInt32(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.StringParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToString(pList<i>));
break;
case CrystalDecisions.Shared.ParameterValueKind.TimeParameter:
rptDocument.SetParameterValue(x.Name, Convert.ToDateTime(pList<i>));
break;
}
}
}
Session["CReport"] = rptDocument;
CRV1.ReportSource = rptDocument;
CRV1.DisplayGroupTree = false;
CRV1.HasRefreshButton = true;
CRV1.ShowFirstPage();
}
Is there a better/different way of accomplishing this very simply process? All I need this application to do is to view a report, while setting it's parmeters (if required) dynamically at run time. I don't EVER want the user to be prompted for DB LOGIN INFO.
Edited by: RichardK on May 10, 2010 4:14 PM
Edited by: RichardK on May 10, 2010 4:14 PM
Edited by: RichardK on May 10, 2010 4:16 PM
Edited by: RichardK on May 10, 2010 4:18 PM
Edited by: RichardK on May 10, 2010 4:22 PM
Edited by: RichardK on May 10, 2010 4:23 PM