0

我開始閱讀本教程利用水晶報表將參數傳遞給存儲過程以進行水晶報告?

http://www.codeproject.com/Articles/142064/Step-by-Step-Creation-of-Crystal-Report-using-its

我面對這種情況,在存儲過程中我必須設置一些參數,以獲得查詢。所以我想我需要在運行時設置dataSource,但我不知道如何將存儲過程結果發送到水晶報表並在運行時顯示它(因爲直到我知道,如果你想顯示它的東西,你有導入,然後選擇要放置的字段。

回答

0
using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Net; 
using System.Text; 
using CrystalDecisions.Web; 
using CrystalDecisions.CrystalReports.Engine; 
using CrystalDecisions.Shared; 

namespace TexERP.ReportCrystal 
{ 
    public partial class AccountRegister : System.Web.UI.Page 
    { 
     clsSession objSession; 
     ReportDocument rptDoc;  
     protected void Page_Load(object sender, EventArgs e) 
     { 
      objSession = new clsSession();   
      rptDoc = new ReportDocument(); 
      if (Session["objSession"] != null) 
      { 
       objSession = Session["objSession"] as clsSession; 
      } 

      if (!IsPostBack) 
      { 
       Session["ReportDataSet"] = null; 
      } 
      if (Session["ReportDataSet"] != null) 
      { 
       crvAccountReportParameter.ReportSource = (ReportDocument)Session["ReportDataSet"]; 
      } 
     } 


     protected void btnSubmit_Click(object sender, EventArgs e) 
     { 
      LoadData();   
     } 
     protected void LoadData() 
     { 
      string pstrType; 
      pstrType = Request.QueryString["Type"]; 
      DataSet dsData = null; 

      dsData = objAccountReportBAL.getAccountRegister(Convert.ToInt16(objSession.FyId), int.MinValue, long.MinValue, Convert.ToDateTime(RadDtpFromDate.SelectedDate), Convert.ToDateTime(RadDtpToDate.SelectedDate), pstrType);   
      rptDoc.Load(Server.MapPath("~/ReportCrystal/Account/Detail/GeneralVoucharRegister.rpt"));   
      rptDoc.SetDataSource(dsData.Tables[0]); 

      Session["ReportDataSet"] = rptDoc; 
      crvAccountReportParameter.ReportSource = rptDoc; 
      crvAccountReportParameter.DataBind();   
     } 
    } 
} 

你可以這樣做........

0

先晶體viewre新形式..加冰糖觀衆在其中..

在該表格中添加此代碼

public void ShowForm(DataSet pDataSet) 
    { 
CrystalDecisions.Shared.ConnectionInfo ConnInfo = new CrystalDecisions.Shared.ConnectionInfo(); 
ReportDocument RepDoc = new ReportDocument(); 
RepDoc.Load(ReportPath With Rpt name); 

TableLogOnInfo TableLogOnInfo; 
     ConnInfo.ServerName = ServerName; 
     ConnInfo.DatabaseName = ServerDBName; 
     ConnInfo.UserID = ServerDBUserName; 
     ConnInfo.Password = ServerDBPassWord; 
     foreach (Table TableInRep in RepDoc.Database.Tables) 
     { 
      TableLogOnInfo = TableInRep.LogOnInfo; 
      TableLogOnInfo.ConnectionInfo = ConnInfo; 
      TableInRep.ApplyLogOnInfo(TableLogOnInfo); 
     } 
CryViewer.ReportSource = RepDoc; 
RepDoc.Database.Tables[0].SetDataSource(pDataSet); 

this.Show(); 

}