简体   繁体   中英

How to show my Crystal Report it does not display

I have with my Crystal Report I did all I could but it's not displaying in the webpage yet it also does not throw any errors and when I tried to host it in IIS, it still does the same yet my Crystal Report displays in the main Report preview (I used a dataset)

This is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data Source=ONE\\SQLEXPRESS;Initial Catalog=tps;Integrated Security=True");

        DataSet ds = new DataSet();
        DataSetTableAdapters.registrationTableAdapter registration = new DataSetTableAdapters.registrationTableAdapter();

        ReportDocument doc = new ReportDocument();
        doc.Load(Server.MapPath("CrystalReport1.rpt"));
        doc.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = doc;
       CrystalReportViewer1.Visible = true;

    }
}

I use this code and its work for me but in PortableDocFormat:

ReportDocument rd = new ReportDocument();
string strRptPath = Server.MapPath("~/") + "Rpts//" + strReportName;

rd.Load(strRptPath);

string userName = ConfigurationManager.AppSettings["UserLogonDb"].ToString();
string password = ConfigurationManager.AppSettings["PasswordLogonDb"].ToString();

rd.SetDatabaseLogon(userName, password);

rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, 
System.Web.HttpContext.Current.Response, false, "crReport");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM