• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

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

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.
0
51685086
Asked:
51685086
  • 8
  • 5
  • 4
  • +1
2 Solutions
 
mlmccCommented:
How are you doing the dynami image from code?

mlmcc
0
 
51685086Author 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());
0
 
mlmccCommented:
What is the conditional formula?

mlmcc
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
frodomanCommented:
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.
0
 
51685086Author 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
0
 
frodomanCommented:
>>> 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).
0
 
51685086Author Commented:
This is a non-networked PC. There is no security. Thanks.
0
 
mlmccCommented:
Which version of C#?

mlmcc
0
 
dylanyeeCommented:
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
0
 
mlmccCommented:
Add this to the formula for the image

WhilePrintingRecords;
{OptionsTable.LogoPath}

mlmcc
0
 
51685086Author 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.
0
 
frodomanCommented:
Are you getting the correct records from your record selection statement when running from your C# project?
0
 
dylanyeeCommented:
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
0
 
51685086Author Commented:
Is there a way to set the formula of the graphic at runtime using the API?
0
 
frodomanCommented:
>>> 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.
0
 
51685086Author Commented:
Yes. It gets the correct records!
0
 
dylanyeeCommented:
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
0
 
51685086Author 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
0
 
51685086Author Commented:
Please split the points evenly between dylanyee and frodoman

Thanks

Mike
0
 
mlmccCommented:
There is a link just below this comment, SPLIT POINTS.

Click that and then follow the directions.

mlmcc
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 8
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now