Print Page | Close Window

.NET questions

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
Printed Date: 03 Jul 2022 at 10:02am

Topic: .NET questions
Posted By: hello
Subject: .NET questions
Date Posted: 12 Mar 2020 at 5:02am

I was hoping there where a few .NET gurus here that could help me understand some basic programming using the CRYSTALDECISIONS.SHARED and CRYSTALDECISIONS.ENGINE assemblies.

First off, here is my Powershell code to load a report, set parameters, and then displays the parameters for viewing on the screen.


$report = New-Object CrystalDecisions.CrystalReports.Engine.ReportDocument

#hard code prompted values here
$customer = '065447'
$location = 1000
$locationsToExclude = 0
$range = New-Object CrystalDecisions.Shared.ParameterRangeValue
$range.StartValue = 1
$range.EndValue = 999

#main report parameter mapping

#sub reports parameter mapping


#$parameterField = New-Object CrystalDecisions.Shared.ParameterField

foreach ($parameterField in $report.DataDefinition.ParameterFields)
        write-output "The current value of:"
        write-output "In report:"
        write-output "is:"
        write-output "Of kind:"
        write-output "-------------------"

What exactly does HASRECORDS do? If I leave out that line, the report has no data and is blank. Is HASRECORDS basically an 'execute' command?

The FOREACH loop at the end simply shows parameter values for each parameter, but the parameters on the sub report never show anything. How do I access the values of the sub reports?

Thanks for any input.

Posted By: hilfy
Date Posted: 20 Apr 2020 at 5:47am
I haven't done this in Power Shell, however, I hope I can point you in the right direction.

1. I would replace "HasRecords" with "Refresh" to run the report.

2. To get to the parameters for the subreport, you actually have to walk through the sections of the report in code to find the subreports and pull the parameters from individual subreports just like you're doing for the main report. In fact, I'm surprised your report is even running because I don't see where you're setting the credentials for the database connections, which you also have to do for each subreport as well as the main report.


Proviti, Data & Analytics Practice -

Print Page | Close Window