×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Passing parameters to report from a program

Passing parameters to report from a program

Passing parameters to report from a program

(OP)
I am using Crystal Reports with Visual Studio 2017. I have written a few reports and all work well in Crystal. However I need to have the parameters validated before printing and to do this I have written a program in C#. I use a button click event to fire the report and my code is as follows:

private void btnPrint_Click(object sender, RoutedEventArgs e)
{
string reportPath = @"C:\qpaq\reports\LedegerTransactionReport.rpt";
CRLedgerTransactionReport ledgerTransactionReport = new CRLedgerTransactionReport();

ledgerTransactionReport.SetParameterValue("Start Account Number", fromAccNumber);
ledgerTransactionReport.SetParameterValue("End Account Number", toAccNumber);
ledgerTransactionReport.SetParameterValue("Start Date", fromDate);
ledgerTransactionReport.SetParameterValue("End Date", toDate);

ledgerTransactionReport.Load(reportPath);

CrystalReportsViewer crystalReportsViewer = new CrystalReportsViewer();
[highlight #FCE94F] crystalReportsViewer.ViewerCore.ReportSource = ledgerTransactionReport;[/highlight]
}

1. When I run the program I get the Crystal "Enter Parameter Values" window appear but the parameters are not populated
2. When I do a trace on the code,I can see the values entered but a trace on the last line,.ReportSource, HasRecords says
" HasRecords threw an exception of type 'CrystalDecision.CrystalReports.Engine.ParameterField(CurrentValueException"
3. I cant understand why the parameters are not being passed, not sure if there is a problem with my code.
4. The parameters above are exactly as created in the Crystal report

I would like to be able run thereport from the program and not have Crystal's "Enter Parameter Values" window displayed

Please assist,
Many thanks

RE: Passing parameters to report from a program

(OP)


HI All,

I have been trying unsucessfully to resolve this error for the past two weeks that I get when trying to pass parameters from my C# program to Crystal reports using C# WPF viewer. I tried it also with a report that does not have parameters and the same error occurs.. My code is above

Does anyone know where I can get access to a complete program listing just to compare idf I am missing anything in my code. I have been searching on the internet for a few days for some guidance, but cannot find anything that is complete

My reports work well if I run them directly in the viewer however, I need to validate certain parameters before printing hence the need to pass the parameters via code

Any assistance will be most appreciated, Many thanks

Bhuven

RE: Passing parameters to report from a program

(OP)
Thank you Ian, I have as well, just thought someone may have experienced a similar problem,
Regards

RE: Passing parameters to report from a program

(OP)
Thank you, I resolved the problem, somewhere in my code i had instantiaited the viewer twice, the parameter were being passed to the second viewer.

Been looking at that code for two weeks before seeing the problem

Many thanks

Regards, bhuven

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close