?
Solved

Can't set report image path at runtime in a crystal report

Posted on 2008-10-27
16
Medium Priority
?
6,633 Views
Last Modified: 2013-11-15
I am having problems with dynamically setting image locations (paths) in Crystal Reports. Just to give you a rundown on the environment I'm using:

I'm designing the reports in Crystal Reports XI Release 2.
- Images loading works fine in the designer.. I can pass it path values from the database or simply give it a path to an image in a string and it works fine, no problem at all. The image is correctly loaded from the specified path.

The problem is at run time.. I'm developing in Microsoft Visual Studio 2008 (version 9.0.21022.8 RMT), which references version 10.5.3700 of the CyrstalReports.Engine to interpret crystal report files.

I have tried using VB.NET code to change a formula field dynamically. I've tried passing in a string parameter with the full or relative path to the image.. and I've also tried loading the image path from a schema in an OLE DB(ADO) style database connection.
None of these have worked, it just loads the default image that I embedded into the report during design time.

To check that the path is being passed correctly each time I loaded it into a text object.

Has anyone got any ideas?
0
Comment
Question by:EricTViking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 3
16 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 22819250
CR 0 epects the image to be in the databse.  It cannot use the file path.  That ability was added in CR XI.

Does CR XI work with VS 2008?

mlmcc
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22819981
I'm using the standalone CR XI R2 designer to create the reports. They are saved as separate *.rpt files.

The app that displays them is built using VS2008, and displays the reports using the report viewer control built into studio.

When deploying to clients I'm installing the 2005 CR redistributable.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22819991
>>I'm using the standalone CR XI R2 designer to create the reports
>>When deploying to clients I'm installing the 2005 CR redistributable

Are you sure its working? I was always told that it wasn't working. You surely not using features that are specific to the full version.
0
Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

 
LVL 11

Author Comment

by:EricTViking
ID: 22820322
Yes...

Create a report in the standalone CR XI R2 designer.

Create a VB.Net app in Studio 2008.

Add a CR report viewer to the VB.Net app.

Load the report into the viewer at runtime.

Works like a charm (apart from you can't load images from file at runtime).

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22820565
I really think that loading images at run time is one of the feature of the standalone version. Why don't you distribute the runtimes for the standalone version?

The only way to provide a dynamic image to the free/lite/in-the-box version of CR is to pass it using a dataset. See http://www.emoreau.com/Entries/Articles/2006/10/Crystal-Reports--Part-II.aspx
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22820697
In the reports created using the standalone version you can set the location of an image. This correctly loads the image from disk when you run the report in the standalone designer. I would have thought this would work when the same report is loaded in the VB.Net report viewer?

On clients we deploy the 2005 .Net runtimes and get the same problem.

Is there a later runtime?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 22820774
If you use the standalone CR XI R2 designer to create your report, you should really deploy the runtime that goes with that version.

The version bundled with Visual Studio is a different version with a different set of features.
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22832614
It seems the problem was caused by the built in report viewer not 'understanding' the image location property.

I downloaded the 30 trial of Crystal 2008 for .Net and installed it. This updated the report viewer component within Studio 2008 and now I am able to set report image paths at runtime.

Will upgrade to Crystal 2008 in 30 days time.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22854421
As emoreau suggested you needed to use the viewer and dlls from the full version of Crystal (CR XI) and not the default viewer used in VS2005 since it is based on CR10.

Accept 22820774 - emoreau

mlmcc
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22856386
That doesn't answer the question as the standalone viewer cannot be embedded in an app. And the DLLs from the CR XI full version make no difference, nor do the runtimes.

The answer is to upgrade to, and install VS2008 for .Net which upgrades the embedded viewer.

0
 
LVL 11

Author Comment

by:EricTViking
ID: 22860762
I have no problem giving emoreau the points and I appreciate his/her input, but this question has now got an accepted solution that is wrong.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22872481
You can embed the viewer in the application.  You may not be able to embed reports with CR XI.

I see no where in your question that indicates the requirement to embed the report in the application.

mlmcc
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22874551
Hi,

There are numerous references to VB.Net here in the original question:

"The problem is at run time.. I'm developing in Microsoft Visual Studio 2008 (version 9.0.21022.8 RMT), which references version 10.5.3700 of the CyrstalReports.Engine to interpret crystal report files.

I have tried using VB.NET code to change a formula field dynamically. I've tried passing in a string parameter with the full or relative path to the image.. and I've also tried loading the image path from a schema in an OLE DB(ADO) style database connection."


The question was also tagged with VB.Net, and one of the zones was .Net.  My first response to you clearly defined the environment.


Quite simply the accepted solution is not correct and should be changed to my original suggestion of 22832614 or this will be a broken solution.

If the wrongly accepted solution can be elaborated on to answer the question I will happily accept it.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22881932
What viewer are you using?  The standalone viewer is a new product from Crystal and you are correct it canot be used with an application.  

However CR XI comes with the tools to use the viewer and a runtime API that should do what you want.

On my machine they are in
Viewer - CRVIEWER.DLL
C:\Program Files\Common Files\Business Objects\3.0\crystalreportviewers11\ActiveXControls

THe only question I cannot answer since I don't have VS2008, is whether these dlls will work with VS2008.  I have not seen anything that indicates they won't work.

mlmcc
API - CRAXDRT.DLL
C:\Program Files\Common Files\Business Objects\3.0\bin


mlmcc
0
 
LVL 11

Author Comment

by:EricTViking
ID: 22882425
I am using the viewer component that comes with Visual Studio 2008. You just create a windows form, and drag the Crystal report viewer control onto it.

Then at runtime, load a crystal report (RPT file) into it programatically.

I am using standalone Crystal reports XI R2 to create the reports, and they load perfectly within the VS 2008 viewer component. The only thing that doesn't work is the ability to change image location at runtime - it's just plain broke.

Installing Crystal 2008 .Net on the machine upgrades the crystal report viewer control that's built into VS 2008, and reports that are rendered from within a VB.Net app that uses the built in viewer are able to dynamically change image location without issue.

Thanks for the tip about the DLLs, but I don't think these will help as the issue is with the report viewer that's built into VS 2008.

0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question