Link to home
Start Free TrialLog in
Avatar of crcsupport
crcsupportFlag for United States of America

asked on

Exporting Crystal report withh dynamic image in C#

I have the following code to export Crystal report to .pdf file ( VS 3.5):

public string Export(ExportFormatType exportformat, string[,] parname_value)
        {
            ReportDocument crReport = new ReportDocument();
            try
            {
                //Load the standalone report
                crReport.Load(_crreportlocation);
                TableLogOnInfo logon=new TableLogOnInfo();
                for (int i = 0; i < crReport.Database.Tables.Count; i++)
                {
                    logon = crReport.Database.Tables[i].LogOnInfo;
                    logon.ConnectionInfo.UserID = "userid";
                    logon.ConnectionInfo.Password = "userpsw";
                    crReport.Database.Tables[i].ApplyLogOnInfo(logon);
                }
                             
                //start export
                DiskFileDestinationOptions dfdo = new DiskFileDestinationOptions();
             
                dfdo.DiskFileName = _exportfilelocation;
                crReport.ExportOptions.DestinationOptions = dfdo;
                crReport.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                crReport.ExportOptions.ExportFormatType = exportformat;
                for (int i = 0; i < _paramcount; i++)
                {
                    crReport.SetParameterValue(parname_value[i, 0], parname_value[i, 1]);
                }

                crReport.Export();
                return "OK";
            }
            catch (Exception ex)
            {
                return "CrystalReport. Export: " +ex.Message;
            }
            finally
            {
                crReport = null;
            }
        }
Report has a dynamic image. When I run the report from Crystal reports all images displayed correctly. If I run the code, the images are not loaded.  When I did the same in VS 2005 I did not have any issues. Any idea what I am doing wrong ?
Thank you
Avatar of Mike McCracken
Mike McCracken

What version of Crystal are you using?

What version of Visual Studio?

Did you update the references to match the version of Visual Studio?

mlmcc
Avatar of crcsupport

ASKER

Crystal Report 11.5 and VS 2008
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i think i can not achieve this in VS 2008. I tried to use Crystal for .net and it doesn't work.
Thank you for your help.
What didn't work using Crystal.Net?

mlmcc