We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

I am trying to use dynamic image location in Crystal XI. It works fine within Crystal Reports, but not from my C# project

51685086
51685086 asked
on
Medium Priority
617 Views
Last Modified: 2008-01-09
I am using Crystal Reports XI Developer Edition. I have defined an image to be dynamic. I set the conditional formula to pull the graphic location from my database. The image displays fine within Crystal Reports. From my C# project, the report displays fine but with the default image, not the dynamic image. Any help would be appreciated.
Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
How are you doing the dynami image from code?

mlmcc

Author

Commented:
I'm not doing anything different from code. The OLE object in Crystal Reports has a formula which simply uses a field in my DB which contains the path to the graphic. When running the report from within Crystal reports, it generates correctly and uses the correct image. When running the report from my program, it uses the default image. It doesn't pull the dynamic image specified in the DB. I am using a local install of Crystal XI and a local install of .Net 2003. The code I use to generate the report is pretty straightforward. The report generates fine, but with the default image. Is there something I need to do in code to use the dynamic image? Thank you in advance.

                  String sPath = System.Configuration.ConfigurationSettings.AppSettings["DSNPath"];

                  String sRpt = System.Configuration.ConfigurationSettings.AppSettings["RptPath"];
                  m_sSource = sRpt + "order.rpt";

                  InitializeComponent();

                  ReportDocument crReportDocument = new ReportDocument ();
                  crReportDocument.Load(sRptPath);

                  Database crDatabase;
                  Tables crTables;
                  Table crTable;
                  TableLogOnInfo crTableLogOnInfo;
                  ConnectionInfo crConnectionInfo = new ConnectionInfo ();

                  crConnectionInfo.ServerName = sMDBPath;
                  crConnectionInfo.DatabaseName = sMDBPath;

                  crDatabase = crReportDocument.Database;
                  crTables = crDatabase.Tables;

                  for (int i = 0; i < crTables.Count; i++)
                  {
                        crTable = crTables [i];
                        crTableLogOnInfo = crTable.LogOnInfo;
                        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                        crTable.ApplyLogOnInfo(crTableLogOnInfo);
                        crTable.Location = sMDBPath;
                  }

                  this.crystalReportViewer1.ReportSource = crReportDocument;
                  string sSel;
                  sSel = "{OrderTable.UniqueID} = " + nID.ToString();
                  this.crystalReportViewer1.SelectionFormula = sSel;

                  crReportDocument.SetParameterValue("nID", nID.ToString());
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
What is the conditional formula?

mlmcc

Commented:
Check to make sure you application has rights to the folder that contains the image.  The security context of your Crystal designer may be different than your application.

Author

Commented:
The conditional formula is simply

{OptionsTable.LogoPath}

LogoPath in OptionsTable is set to C:\speedsequation.jpg

I don't understand the other comment made as to the security context of Crystal Designer?

The report was developed within Crystal Reports XI, not using the report designer within .Net

Commented:
>>> I don't understand the other comment made as to the security context of Crystal Designer?

This means that when you run your application, it is running in some type of security context - it's running as the logged on user or as a local service or whatever.  However the application is running it may not have read rights to the location of the .jpg file (the c:\ root in this case).

Author

Commented:
This is a non-networked PC. There is no security. Thanks.
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Which version of C#?

mlmcc

Commented:
51685086, could you do a simple testing? in your graphic location formula, simply type in the picture's location eg) "C:\speedsequation.jpg", then run it from c#. If you could get your image changed correctly, then the problem should be at database side. If you can't get the image correctly... then must be something to do with CR. that we will find out.

dylan
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Add this to the formula for the image

WhilePrintingRecords;
{OptionsTable.LogoPath}

mlmcc

Author

Commented:
I tried putting the path directly in the report. It works from Crystal, but not from my 2003 C#.Net project. I also tried the WhilePrintingRecords command and it didn't work either. Thanks in advance.

Commented:
Are you getting the correct records from your record selection statement when running from your C# project?
Commented:
i think at the moment we shouldn't consider retrieve the image file path from database anymore first, since 51685086's testing indicate that the formula even doesn't work from c# runtime when he key in the file path directly in the formula.

I can't think of any other possible solution... probably you can try upgrade to CR XI release 2. although Crystal Decision said that you need CRXI R2 only if you are running VS.NET 2005, but since it is an upgrade from release 1, its worth to give it a try. you could download from here:
http://www.businessobjects.com/products/reporting/crystalreports/compatibility_vs2005.asp

dylan

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Is there a way to set the formula of the graphic at runtime using the API?
Commented:
>>> Are you getting the correct records from your record selection statement when running from your C# project?

I was going for making sure that there isn't a problem with his application pulling the report - maybe saved or cached data or a duplicate refresh where the parameters get lost, etc.

Author

Commented:
Yes. It gets the correct records!

Commented:
51685086, I don't think you could set the formula of the graphic at runtime using API, you could either use database field or parameter field.
Did you consider to upgrade to CRXI Release 2? its free to upgrade, it share the same key with Release 1.

dylan

Author

Commented:
OK. A $195 call to Business Objects and I have an answer. Crystal Reports XI MUST be installed after .Net 2003 or the assemblies don't get set correctly. So, uninstalling Crystal Reports, resetting the computer and then reinstalling Crystal Reports fixes the problem. Thank you to everyone to helped me along the way.

Regards,

Mike

Author

Commented:
Please split the points evenly between dylanyee and frodoman

Thanks

Mike
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
There is a link just below this comment, SPLIT POINTS.

Click that and then follow the directions.

mlmcc
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.