Solved

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

Posted on 2008-10-27
16
6,409 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
  • 8
  • 4
  • 3
16 Comments
 
LVL 100

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 69

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
 
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 69

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 69

Accepted Solution

by:
Éric Moreau earned 500 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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 100

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 100

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 100

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
How to increase the row limit in Jasper Server.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now