Solved

Crystal Reports viewer Blank in production

Posted on 2012-04-10
12
777 Views
Last Modified: 2012-04-18
I have a report that works correctly in development but in production displays a blank page.
built in Visual Studios 2010.

I receive no Errors


string reportPath = Server.MapPath("~/Reports/" + _reportData.ReportNameCR);
rptReport.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
WebMsgBox.Show(_reportData.ReportDataset.Tables[0].Rows.Count.ToString()); // this pops an alert box that shows the correct row count
rptReport.SetDataSource(_reportData.ReportDataset);
crReportViewer.ReportSource = rptReport;
crReportViewer.DataBind();

Open in new window


the WebMsgBox.Show line pops an alert box.  if I move this after
rptReport.SetDataSource(_reportData.ReportDataset);

Open in new window

then it never pops.  So it is something to do with the setDataSource, but i am stumped

the production server is windows 2008 r2 sp1
0
Comment
Question by:jfb1126
  • 7
  • 5
12 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 37830931
Is this against the same database as you developed it?

mlmcc
0
 

Author Comment

by:jfb1126
ID: 37834849
it is a local copy of the same DB.  the data there is the same.  the site is connecting to the db fine.  as mentioned above, I put an alert telling me the # of records, so I know the Dataset is populated.  it appears to hang when I invoke the SetDataSource method.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37834949
SO when you run from within VS2010 it is using a local database and when run on the web it uses a different database?

How are you loading the dataset?

Was the report built using a recordset or built against a database?

mlmcc
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:jfb1126
ID: 37834990
the dataset is loaded through the business object.  the report was built against an XSD file.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37835066
If you put a webmsgbox after that line you never see it?

I don't use that version so I don't know what the issue is.

mlmcc
0
 

Author Comment

by:jfb1126
ID: 37835522
Nope, the message box never shows after the SetDataSource()  

thanks for trying.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37835600
How is rptReport declared?

mlmcc
0
 

Author Comment

by:jfb1126
ID: 37835634
here's the full code.  the report name and any parameters (and parameter Types) are passed into the page.  

ReportData is my business object that loads the dataset.  


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using GranitizeWarehouseDataObjects;
using Tools_jfb;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports.Engine;

namespace GranitizeWarehouseWebsite
{
    public partial class ReportViewer : GranitizePage
    {
        private ReportData _reportData;
        private ReportDocument rptReport;
        private String rptName;
        private String ThisPage;
        private Boolean QuickPrint;

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                rptReport = new ReportDocument();
                ThisPage = "http://" + Request.ServerVariables["SERVER_NAME"] + Request.ServerVariables["URL"] + "?" + Request.QueryString;


                if (Request["report"] == null)
                    throw new ArgumentException("Report Not Set");
                else
                    rptName = (String)Request["report"];

                this.Title = "Granitize S.O.S. - " + Request["report"];
                _reportData = new ReportData(rptName, CurrentUser);

                //Setup Navigation Links
                String http_Referrer = "";
                http_Referrer = Request.ServerVariables["http_referer"];
                if (http_Referrer != null)
                {
                    if (http_Referrer.IndexOf("ReportViewer") == -1)
                        Session["HTTP_REF"] = Request.ServerVariables["http_referer"];
                }
                linkBack.NavigateUrl = (String)Session["HTTP_REF"];
                if (_reportData.ReportNameCR == "reportPickingSheets.rpt")
                {
                    linkOther.Text = "Continue Processing ->";
                    linkOther.NavigateUrl = "~/EditWhsOrderStatus.aspx?ParamValues=" + Request["ParamValues"];
                    linkOther.Visible = true;
                }

                _reportData.loadPrarameters(Request["ParamName"], Request["ParamValues"], Request["objType"]);
                _reportData.Fill();


                if (Request["C"] == "1")
                {
                    _reportData.ReportDataset.DataSetName = rptName + "_DS";
                    WriteReportSchema(_reportData.ReportDataset);
                }
                else
                {

                    string reportPath = Server.MapPath("~/Reports/" + _reportData.ReportNameCR);
                    rptReport.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
                    WebMsgBox.Show(_reportData.ReportDataset.Tables[0].Rows.Count.ToString());
                    rptReport.SetDataSource(_reportData.ReportDataset);
                    crReportViewer.ReportSource = rptReport;
                    crReportViewer.DataBind();
                }

                if (Request["QuickPrint"] == "1")
                {
                    QuickPrint = true;
                }
            }
            catch (Exception ex)
            {
                //     Response.Write(ex.Message + "<br/><br/>" + ex.Source + "<br/><br/>" + ex.StackTrace + "<br/><br/>" + ex.Data + "<br/><br/>" + ex.InnerException);
                WebMsgBox.Show(ex.Message);
            }
        }//END Page Load
        protected void Page_Unload(object sender, EventArgs e)
        {   
            if (rptReport !=null)
                rptReport.Dispose();
            if (QuickPrint)
            {
                btnExport_Click(sender, e);
               /* System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
                sb.Append("window.opener.BackFromPopup();");
                sb.Append(@"self.close(); ");
                sb.Append(@"</script>");
                ClientScript.RegisterStartupScript(GetType(), "cwin", sb.ToString());*/
            }
        }
        private void ConfigureCrystalReports()
        {
        }

        public void WriteReportSchema(DataSet reportData)
        {
            String path = Server.MapPath("Reports/App_Code/");
            reportData.WriteXmlSchema(path + _reportData.FileName);
        }
       
    }//END CLASS
}

Open in new window

0
 

Author Comment

by:jfb1126
ID: 37838381
OK, I made a little progress, the report is loading now (I know this because I can now export it as before I could not), but the viewer still displays blank.

changed line
rptReport.SetDataSource(_reportData.ReportDataset);

Open in new window

to this:
 DataSet ds = _reportData.ReportDataset;
rptReport.SetDataSource(ds);

Open in new window

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37840858
Is there more than 1 page?

The viewer starts on page 1 which could be blank

mlmcc
0
 

Accepted Solution

by:
jfb1126 earned 0 total points
ID: 37843122
RESOLVED:

as described above, declaring a local dataset and setting it = to the one returned by my business object instead of using the business object directly worked to load the report

the non- display issue was resolved by putting a virtual directory on my website pointing to the crystal reports folder on my server
0
 

Author Closing Comment

by:jfb1126
ID: 37859695
I solved this myself
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question