在Crystal Report中使用存储过程参数并在运行时更改数据库位置 [英] Using Stored Procedure Parameter and changing Database Location at run-time in Crystal Report
问题描述
我使用Crystal Report for .Net 2005(Crystal Ver.10.2.3600.0),MSSQL 2000
,其中我创建了一个具有两个参数的存储过程。我是
使用此存储过程在Crystal Report中打印报表。我通过ASP.Net页面将
参数传递给此存储过程。这可以
罚款,但是如果我将此报告用于不同的数据库服务器或不同的
数据库并使用DBLogonInfo为报告中的存储过程
设置新位置,则显示报告但参数critaria已被接受
和报告未显示在范围内。
我的代码如下:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
导入CCPL.Crystal.ReportObject
'DLL是指传递报告信息&实用函数
部分类_Default
继承System.Web.UI.Page
受保护的子Page_Init(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Init
Try
Dim
objCrystalReport As New CrystalReportObject'Object使用
来传递报告信息
Dim objReport As New ReportDocument
objCrystalReport = CType(Session(" ReportObject"),CrystalReportObject)
objReport.Load(objCrystalReport.ReportFileName)
objCrystalReport.SetDBLogon(objReport)
objReport.Refresh()
objCrystalReport.SetValuesForParameterField(objReport)
objCrystalReport.ApplyFormulas(objReport)
ReportViewer.ReportSource = objReport
Catch ex As Exception
MsgBox(ex.Message,MsgBoxStyle.Critical," Display Report")
结束尝试
End Sub
结束类
请参阅以下示例,了解如何将位置设置到其他服务器:
企业样本(包括托管和非托管ras)
http://wiki.sdn.sap.com/wiki/display/BOBJ/Business+Objects+SDK+Sample+Applications
非企业样本>
http://wiki.sdn.sap.com/wiki/display/BOBJ/Crystal+Reports+SDK+Sample+Applications
出口样品(RAS)
http://wiki.sdn.sap.com/wiki/display/BOBJ/NET+RAS+SDK+Samples#NETRASSDKSamples-Exporting%2FPrinting
唐
I use Crystal Report for .Net 2005(Crystal Ver.10.2.3600.0), MSSQL 2000
where I have created an Stored Procedure having two paramenters. I am
using this Stored procedure to print a Report in Crystal Report. I pass
parameter to this Stored procedure through ASP.Net Page. This works
fine but if I use this Report for diffrent DB Server or diffrent
Database and use DBLogonInfo to set new location for stored procedure
in Report, Report is Displayed but parameter critaria is on accepted
and report is not displayed within the range.
My Code is as Following
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CCPL.Crystal.ReportObject
' DLL refered to pass report information & Utility Functions
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Try
Dim
objCrystalReport As New CrystalReportObject ' Object used
to pass report information
Dim objReport As New ReportDocument
objCrystalReport = CType(Session("ReportObject"), CrystalReportObject)
objReport.Load(objCrystalReport.ReportFileName)
objCrystalReport.SetDBLogon(objReport)
objReport.Refresh()
objCrystalReport.SetValuesForParameterField(objReport)
objCrystalReport.ApplyFormulas(objReport)
ReportViewer.ReportSource = objReport
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Display Report")
End Try
End Sub
End Class
See these samples for how to set location to another server:
Enterprise Samples (including managed and unmanaged ras)
http://wiki.sdn.sap.com/wiki/display/BOBJ/Business+Objects+SDK+Sample+Applications
Non-Enterprise Samples
http://wiki.sdn.sap.com/wiki/display/BOBJ/Crystal+Reports+SDK+Sample+Applications
Exporting Samples (RAS)
http://wiki.sdn.sap.com/wiki/display/BOBJ/NET+RAS+SDK+Samples#NETRASSDKSamples-Exporting%2FPrintingDon
这篇关于在Crystal Report中使用存储过程参数并在运行时更改数据库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!