2017-06-12 277 views
0
using CrystalDecisions.CrystalReports.Engine; 
using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Data.SqlClient; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
public partial class _Default : System.Web.UI.Page 
{ 
    SqlConnection con = new SqlConnection("Data Source=DESKTOP;Initial Catalog=TestDB;Integrated Security=True"); 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      ReportDocument doc = new ReportDocument(); 
      doc.Load(Server.MapPath("~/UserList.rpt")); 
      DataSetSample ds = getdata(); 
      doc.SetDataSource(ds); 
      CrystalReportViewer1.ReportSource = doc; 
     } 
    } 
    public DataSetSample getdata()//.xsd file 
    { 
     con.Open(); 
     SqlCommand cmd = new SqlCommand("select * from tblUser", con); 
     SqlDataAdapter da = new SqlDataAdapter(cmd); 
     DataSetSample ds = new DataSetSample(); 
     da.Fill(ds, "DataTable1"); 
     return ds; 
    } 
} 

我手動使用了水晶報告。這是我的.cs文件代碼。代碼顯示沒有錯誤,但在瀏覽器上顯示空白網頁。無法找到錯誤......Crystal Report在Crystal Report Viewer中未顯示數據使用VS 2013

回答

0

下載最新版本的支持VS2013的水晶報表,然後參考this鏈接。

+0

先生我有最新版本,它在嚮導水晶報告中工作,但不能手動工作 – Haroon

+0

@Haroon將你的代碼放在try和catch塊中,看看你面對的是哪個錯誤。 –

0

如果您已經安裝了正確的水晶運行時間,你可以調試報告,而不是在IIS託管時運行它們時,空白的屏幕顯示您正在處理這個問題:Crystal Report with Visual studio 2013 aspnet_client/system_web/4_6_81

您可以證實這一點從瀏覽器中打開F12開發人員工具。您應該注意到一些錯誤與錯誤的JavaScript文件(如crv.js和某些css文件)相關,如C:\ inetpub \ wwwroot \ aspnet_client \ system_web \ 4_XXXXXX。

它涉及.Net框架的自動更新以及Crystal運行時如何引用其靜態內容。 SAP是aware of this

您可以將文件夾複製作爲臨時解決方法:複製C:\的Inetpub \ wwwroot的\ aspnet_client \ system_web \ 4_0_30319到C:\的Inetpub \ wwwroot的\ aspnet_client \ system_web \ 4_6_XXXXX基於由404錯誤報道的道路上你的開發者工具。