Change a Picture in Crystal Reports using parameters C#

ocortes
ocortes used Ask the Experts™
on
Hello,
I have a report that is built from a stored procedure in Crystal Reports for .net using C#. The report shows all the rows retuned from the stored procedure with fiields from my database (SQL server 2000). I need to change the logo on top of the report using a parameter that the user selects in a windows form. The code to call the report is:

PMIIntransit orpt = new PMIIntransit();
orpt.SetParameterValue("@date1", dtpDate1.Value.ToShortDateString() + " 12:00:00 AM");
orpt.SetParameterValue("@date2", dtpDate2.Value.ToShortDateString() + " 11:59:00 PM");
crystalReportViewer1.ReportSource = orpt;
crystalReportViewer1.Zoom(75);

I can add a parameter to select between logo1.jpg or logo2.jpg like this
orpt.SetParameterValue("Logo", "path");
Where path will have the path to logo1 or logo2 but I don't really know how to change the picture path in the report.
Any help will be appreciate it.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
is it the Crystal Reports version that is bundled with Visual Studio? if so, this version cannot read an image from a path. check http://www.emoreau.com/Entries/Articles/2006/10/Crystal-Reports--Part-II.aspx

Author

Commented:
Yes, it is the version bundled in Visual Studio. So I won't be able to change the picture dynamically?
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
not using a path but you can load your picture into a dataset and push it to your report like I do in my article
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Author

Commented:
Hi emoreau,
I saw your article but I don't know how to apply it to my problem. I don't have a schema. I create the report from a stored procedure that returns fields from multiple tables in my db and I just display the data in the details section of the report. I don't think it will make sense to add a field to one of the actual tables in the db for the image and there is no type byte on them. Do you know how to do it?
Thank you
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
instead of having the report connected to the stored proc, connect it to a schema (and load your SP into the same dataset)

Author

Commented:
I'll give it a try
Thank you
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
You could also put all logos on the report and suppress the ones you don't want based on the parameter

mlmcc

Author

Commented:
mlmcc
That sounds easier than recreate the report using the schema, but do you have to put each logo on a different section of the report and then suppress the section based on the parameter or where you put the code to suppress or show just the picture?
Thank you

Author

Commented:
I figure out how to put the formula on the picture and supress it. I worked great. Thank you
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Either way works.

Personally I would probably use separate sections since that would make updating logos easier.

mlmcc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial