水晶报表 Issue

pull模式 代码如下

private void ShowCrystalReport()
{
string strDBServer = Application["DBServer"].ToString();
string strDBName = Application["DBName"].ToString();
string strUserId = Application["DBUserID"].ToString();
string strPassword = Application["DBPassword"].ToString();
//连接代码
CrystalReportSource1.ReportDocument.Load(Server.MapPath("Report/JPInvoice.rpt"));
CrystalReportSource1.ReportDocument.SetDatabaseLogon(strUserId, strPassword, strDBServer, strDBName);
//设置参数
CrystalReportSource1.ReportDocument.SetParameterValue("Invoice_No_From", strInvoiceForm);
CrystalReportSource1.ReportDocument.SetParameterValue("Invoice_No_To", strInvoiceTo);
CrystalReportSource1.ReportDocument.SetParameterValue("TRX_Date_From", strDateFrom);
CrystalReportSource1.ReportDocument.SetParameterValue("TRX_Date_To",strDateTo );
CrystalReportSource1.ReportDocument.SetParameterValue("Org_ID", "86");
CrystalReportSource1.ReportDocument.SetParameterValue("SOB_ID", "2029");
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
}

 开始遇到的问题是 “无法加载数据库 crdb_oracle.dll

解决方法: 
1) 找到 crdb_oracle.dll.

«C:\Program Files\Common Files\Business Objects\3.0\bin»或者在

 «C:\Program Files\Common Files\Crystal Decisions\2.0\bin»中(Crystal 9)
2)Copy to «C:\Program Files\Common Files\Business Objects\2.7\Bin 
3)Reload solution.

 

后来又遇到问题 您请求的报表需要更多信息 如图:

首先检查DBServer和用户名密码是否配置正确,重新编译一次。

另外 修改了代码

 private void ShowCrystalReport()
        {
          
            TableLogOnInfo log = new TableLogOnInfo(); 
            ReportDocument rd = new ReportDocument();

            log.ConnectionInfo.ServerName = Application["DBServer"].ToString();
            log.ConnectionInfo.Password = Application["DBPassword"].ToString();
            log.ConnectionInfo.UserID = Application["DBUserID"].ToString();
            log.ConnectionInfo.DatabaseName = Application["DBName"].ToString();

            rd.Load(Server.MapPath("Report/JPInvoice.rpt"));

            rd.SetParameterValue("Invoice_No_From", strInvoiceForm);
            rd.SetParameterValue("Invoice_No_To", strInvoiceTo);
            rd.SetParameterValue("TRX_Date_From", strDateFrom);
            rd.SetParameterValue("TRX_Date_To", strDateTo);
            rd.SetParameterValue("Org_ID", "86");
            rd.SetParameterValue("SOB_ID", "2029");

         
            rd.Database.Tables[0].ApplyLogOnInfo(log);//获得第一个table

            CrystalReportViewer1.ReportSource = rd;
            CrystalReportViewer1.DataBind(); 
        }

  

 

 

 

posted @ 2014-02-07 13:31  过客人生  阅读(847)  评论(3编辑  收藏  举报