on 09-16-2008 5:50 PM
Background:
I am developing a .NET web application using Visual Studio 2005. The code behind is in VB.net. One of my asp.net pages calls a report, which is invoked when the user clicks a Print button. I have developed this report using the Crystal Reports software that is bundled with Visual Studio 2005. I am passing one parameter from the asp.net page (utilizing the VB.net code-behind on the Print button) to the Crystal report. The report consists of a main report and 5 subreports. Both the main report and the subreports use the same parameter. Both the main report and the subreports are bound to stored procedures, each of which require a parameter.
Problem:
For some reason, the parameter is not being passed from the asp.net page to the report. I am receiving the following error: "CrystalDecisions.CrystalReports.Engine.ParameterField.CurrentValueException: Missing Parameter Values." However, when I remove the subreports, the parameter gets passed, and the report is invoked with no problem.
I have read in other forums that there may be an issue with the Crystal Reports software that is causing this problem. I have downloaded and run the suggested hotfix, but the problem remains unresolved. I have tried changing the linking of my main report to the subreport, but that doesn't help either. It is possible that I am doing something wrong with the linking, as this is the first time I have developed a report with Crystal Reports. I need a workaround or definitive solution. Below is the aspx code used to call the report:
Imports System
Imports System.Collections.Specialized
Imports System.Collections.ObjectModel
Imports System.Collections
Imports System.Text
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.SqlClient.SqlDataAdapter
Imports System.Web.Configuration
Imports Crystaldecisions.crystalreports.engine
Imports Crystaldecisions.reportsource
Imports Crystaldecisions.shared
Partial Class OACIS_Award_or_Deny_BudgetSummary_PrintRpt
Inherits System.Web.UI.Page
Dim paramFields As ParameterFieldDefinitions
Dim paramField As ParameterFieldDefinition
Dim paramValue As ParameterValues
Dim paramDiscreteValue As New ParameterDiscreteValue
Public Shared idCase, nameRpt As String
Private PrintRpt As ReportDocument
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
idCase = Request.QueryString("id")
nameRpt = Request.QueryString("prtName")
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~/")
Dim settings As AppSettingsSection = DirectCast(config.GetSection("appSettings"), AppSettingsSection)
Dim file As String = settings.File
Dim dSource, iCatalog, userIs, passUser, appString As String
dSource = Nothing
iCatalog = Nothing
userIs = Nothing
passUser = Nothing
appString = config.ConnectionStrings.ConnectionStrings("OacisConn").ToString()
Dim AppArray() As String = Split(appString, ";")
Dim arrayLgth As Integer = AppArray.Length
Dim i As Integer
For i = 0 To arrayLgth - 1
Dim pairIs() As String = Split(AppArray(i), "=")
Dim firstItem As String = pairIs(0)
Dim secondItem As String = pairIs(1)
If firstItem = "Data Source" Then : dSource = secondItem : End If
If firstItem = "Initial Catalog" Then : iCatalog = secondItem : End If
If firstItem = "UID" Then : userIs = secondItem : End If
If firstItem = "PWD" Then : passUser = secondItem : End If
Next
Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim crconnectioninfo As ConnectionInfo
Dim crDatabase As Database
Dim crtables As Tables
Dim crtable As Table
Dim crtablelogoninfo As TableLogOnInfo
Dim Fname As String
Dim Prtname As String
Dim FPath As String
Dim crSection As Section
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
FPath = Server.MapPath("") + "\"
Dim rptIs As String = nameRpt
crReportDocument = New ReportDocument
Prtname = FPath
Prtname = Prtname + rptIs
crReportDocument.Load(Prtname)
Fname = "C:\WINDOWS\TEMP\" & Session.SessionID.ToString & ".pdf"
crconnectioninfo = New ConnectionInfo
crconnectioninfo.ServerName = dSource
crconnectioninfo.DatabaseName = iCatalog
crconnectioninfo.UserID = userIs
crconnectioninfo.Password = passUser
crDatabase = crReportDocument.Database
crtables = crDatabase.Tables
For Each crtable In crtables
Try
crtablelogoninfo = crtable.LogOnInfo
crtablelogoninfo.ConnectionInfo = crconnectioninfo
crtable.ApplyLogOnInfo(crtablelogoninfo)
crtable.SetDataSource(Prtname)
crtablelogoninfo.ConnectionInfo.DatabaseName = iCatalog
crtablelogoninfo.ConnectionInfo.UserID = userIs
crtablelogoninfo.ConnectionInfo.Password = passUser
crtable.ApplyLogOnInfo(crtablelogoninfo)
crtable.Location = iCatalog + ".dbo." + crtable.Name
Catch ex As Exception
Response.Write(ex)
Exit Sub
End Try
Next crtable
For Each crSection In crReportDocument.ReportDefinition.Sections
For Each crReportObject In crSection.ReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
crSubreportObject = CType(crReportObject, SubreportObject)
subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
For Each crtable In subRepDoc.Database.Tables
Try
crtablelogoninfo = crtable.LogOnInfo
crtablelogoninfo.ConnectionInfo = crconnectioninfo
crtable.ApplyLogOnInfo(crtablelogoninfo)
crtable.SetDataSource(Prtname)
crtablelogoninfo.ConnectionInfo.DatabaseName = iCatalog
crtablelogoninfo.ConnectionInfo.UserID = userIs
crtablelogoninfo.ConnectionInfo.Password = passUser
crtable.ApplyLogOnInfo(crtablelogoninfo)
crtable.Location = iCatalog + ".dbo." + crtable.Name
Catch ex As Exception
End Try
Next
End If
Next
Next
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
Dim parIDCase As ParameterValues = New ParameterValues
Dim disIDCase As ParameterDiscreteValue = New ParameterDiscreteValue
disIDCase.Value = idCase
parIDCase.Add(disIDCase)
crReportDocument.DataDefinition.ParameterFields("@ID_CASE_NMBR").ApplyCurrentValues(parIDCase)
crReportDocument.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
Catch ex As Exception
lblMessage.Visible = True
lblMessage.Text = "Error Load<br>" & Convert.ToString(ex)
End Try
End Sub
End Class
Your help is greatly appreciated!
Edited by: LaShandra Knox on Sep 16, 2008 7:16 PM
If you are having issue with .Net application then post your question here:
[.NET Development - Crystal Reports Forum|https://www.sdn.sap.com/irj/sdn/businessobjects-sdk-forum]
Hope that helps!!
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.