Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2005, 02:57 AM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default problems with Exporting and Viewer

Hi, i'm having troubles using the ReportViewer to export to a pdf. Parameters are set by the user and (depending on the report) programmatically.
When i try to export in my code, i get a "Missing Parameter Values" error.
However, if i try to open a report with no parameters - the export works fine.

Can someone please help me out? Why is it not 'remembering' the parameters when it exports?

Here's my code:

this is the Export code: It's called when the user clicks a button

<code>
private void Export4()
{
     string ExportPath;
     ExportPath = Request.PhysicalApplicationPath + "Exported\\";

     if (Directory.Exists(ExportPath) == false)
           Directory.CreateDirectory(Request.PhysicalApplicat ionPath + "Exported\\");

          crDiskFileDestinationOptions = new DiskFileDestinationOptions();
          crExportOptions = reportDocument1.ExportOptions;
          crDiskFileDestinationOptions.DiskFileName =ExportPath + "PortableDoc.pdf";
          crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
          crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
          crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                     try
        {
         reportDocument1.Export();
         }
         catch (Exception err)
         {
                  Response.Write("<BR>");
                  Response.Write(err.Message.ToString());
          }
}
</code>


And this is the code that sets the parameters, report and Viewer: This code is called in the Page_init

<code>


public void LoadReport_Param(ref CrystalReportViewer crViewer, ref ReportDocument crReport)
{
TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Database crDatabase;
CrystalDecisions.CrystalReports.Engine.Tables crTables;
ParameterDiscreteValue crPDValue;
ParameterFieldDefinitions crPFDefs;
ParameterFieldDefinition crPFDef;
ParameterValues crPValues;
try
     {
    crConnInfo.ServerName = _servername;
    crConnInfo.DatabaseName = _dbname;
    crConnInfo.UserID = _username;
    crConnInfo.Password = _password;
    crDatabase = crReport.Database;
    crTables = crDatabase.Tables;

              foreach(CrystalDecisions.CrystalReports.Engine.Tab le crTable in crTables)
            {
    crTableLogOnInfo = crTable.LogOnInfo;
    crTableLogOnInfo.ConnectionInfo = crConnInfo;
    crTable.ApplyLogOnInfo(crTableLogOnInfo);
             }
    crPFDefs = crReport.DataDefinition.ParameterFields;
            for (int intParamCounter = 0; intParamCounter <= crPFDefs.Count-1; intParamCounter++)
            {
    try
    {
    crPFDef = crPFDefs[intParamCounter];
    crPValues = crPFDef.CurrentValues;
    if ((_GroupABBR != "") || (crPFDef.ParameterFieldName == "Branch") ||
(crPFDef.ParameterFieldName == "@Branch")|| (crPFDef.ParameterFieldName == "?Branch") || (crPFDef.ParameterFieldName.ToLower() == "branch"))
    {
    crPDValue = null;
    crPDValue = new ParameterDiscreteValue();
    crPDValue.Value = _GroupABBR;
    crPValues.Add(crPDValue); crPFDef.ApplyCurrentValues(crPValues);
    }
              }

    catch (EngineException engEx)
    {
          throw new Exception(engEx.Message);
    }
             }
    crViewer.ReportSource= crReport;
    }
    catch (LogOnException engEx)
    {
                     throw new Exception("Incorrect Logon Parameters. Check your user name and password.");
    }
    catch (DataSourceException engEx)
    { throw new Exception("An error has occurred while connecting to the database.");
    }
    catch (EngineException engEx)
    {
         throw new Exception(engEx.Message);
    }
            }
</code>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Viewer pushpa ASP.NET 1.0 and 1.1 Basics 2 April 13th, 2007 05:56 PM
Document viewer baburman General .NET 4 November 2nd, 2006 05:12 AM
ActiveX Viewer mohithmohith Crystal Reports 0 August 27th, 2004 10:46 AM
Viewer error Ned Crystal Reports 1 July 23rd, 2004 10:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.