本文介绍了在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 结束类 解决方案 I use Crystal Report for .Net 2005(Crystal Ver.10.2.3600.0), MSSQL 2000where I have created an Stored Procedure having two paramenters. I amusing this Stored procedure to print a Report in Crystal Report. I passparameter to this Stored procedure through ASP.Net Page. This worksfine but if I use this Report for diffrent DB Server or diffrentDatabase and use DBLogonInfo to set new location for stored procedurein Report, Report is Displayed but parameter critaria is on acceptedand report is not displayed within the range. My Code is as FollowingImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.SharedImports CCPL.Crystal.ReportObject ' DLL refered to pass report information & Utility FunctionsPartial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init Try DimobjCrystalReport As New CrystalReportObject ' Object usedto 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 SubEnd Class 解决方案 这篇关于在Crystal Report中使用存储过程参数并在运行时更改数据库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 09:17