how to get parameter fields from ASP .NET to CR

Hi all,
I am writing a ASP .NET program (C#) to view a CR (8.5), and the CR takes a fews parameter fields, how can I use C# API to pass the parameter fields to CR to output the report?

one  more question is, when I view the CR (directly), it will prompt for sql connection username and password, I have made  a  file dsn for the connection, and it prompt out for these info everytime I view the report, can I pass these fields by using ASP.NET API too? Thanks a lot!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

// Create report instance
private ReportDocument reportDocument = new ReportDocument();

// Assign values to instance
reportDocument.Load(strLocation);  // location of report
reportDocument.SetDatabaseLogon(dbUser,dbPass); // username and password for DB access

// Assign parameters to report

You didn't mention what you want to do with the report.  Your options are to sent it to a viewer, export or print.

// Print
reportDocument.PrintOptions.PrinterName = printerName;
reportDocument.PrintToPrinter(1, false, 0, 0);

// Export - This will require export options to be defined.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ultrafishAuthor Commented:
if I have to choose the datasource like
how can I choose it?
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ultrafishAuthor Commented:
also, I cannot find the method SetDatabaseLogon and SetParameterValue method
which library has to be imported?

and if I want to print directly, how can I do that? thanks
I have never needed to choose a dsn.  I did a quick check and ReportDocument has a parameter:


Hope this helps.  Thanks for the points ultrafish, this is my first accepted response (also my first day to be a member of EE).  Good Luck.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

Is "reportDocument" working at all for you?

What do you mean by printing directly?
ultrafishAuthor Commented:
is that only exist in 2003 and CR 9.0?
I am using CR 8.5 and VS.NET 2002 only, I don't have the method SetDatabaseLogon() and SetParameterValue()
Ahhh, You weren't specific about your .Net development environment.  You referenced CR 8.5 but I understand that as a reference to what version the reports were originally written in.  I don't know if CR 8.5 components in 2002 would be similar to the code I posted.  What I posted is from a working program in .Net 2003 with CR 9.0 (Crystal Decisions).  Hopefully mlmcc's link will provide the information you need.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.