pull模式 代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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”
解决方法:更新pack,由于用的是vs2008 所以安装了VS2008SP1
后来又遇到问题 您请求的报表需要更多信息 如图:
解决方法 修改了代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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);
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.DataBind();
}
|