472,354 Members | 1,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Crystal Reports .NET - can't view a report more than once


I was trying to run a crystal report in the .net sample application
given at:


(I've reproduced the relevant file below.)

However, I want to view the report three times in a row.

I tried replacing:

Application::Run(new ViewForm());

at the end of the file with:
Application::Run(new ViewForm());
Application::Run(new ViewForm());
Application::Run(new ViewForm());

However, the second time Run() is called, the viewer comes up, then
disappears immediately. It works fine the third time. I checked, and
it works fine every odd time, and fails every even time.

Anyone have any idea what I'm doing wrong?

Thanks muchly,


//Created: March 27, 2002
//Author ID: TDU
//Purpose: This C++ .NET sample Windows application demonstrates
how to
// pass multiple values to a single discrete parameter
// using the engine object model.

//Both of these CR assemblies are required to be able to
//access, load, and set database logon.

#include "stdafx.h"

#using <mscorlib.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <CrystalDecisions.Shared.dll>
#using <CrystalDecisions.Windows.Forms.dll>
#using <CrystalDecisions.CrystalReports.Engine.dll>

using namespace System;
using namespace System::Windows::Forms;
using namespace CrystalDecisions::Shared;
using namespace CrystalDecisions::CrystalReports::Engine;
using namespace CrystalDecisions::Windows::Forms;

// This is the main form that will hold the viewer control.
__gc class ViewForm : public System::Windows::Forms::Form
//Declare the Viewer Control, Report Document, and other
//objects needed to set the Parameter values.

CrystalDecisions::Windows::Forms::CrystalReportVie wer* crViewer;
ReportDocument* crReportDocument;
ParameterFieldDefinitions* crParameterFieldDefinitions;
ParameterFieldDefinition* crParameterFieldDefinition;
ParameterValues* crParameterValues;
ParameterDiscreteValue* crParameterDiscreteValue;

//Public constructor
InitForm() ;
this->Dispose() ;

void InitForm()
//This function initializes the form and adds the viewer to the
// Instantiate the viewer control and add it to the form
this->crViewer = new
CrystalDecisions::Windows::Forms::CrystalReportVie wer();
this->crViewer->ActiveViewIndex = -1;
this->crViewer->Dock = System::Windows::Forms::DockStyle::Fill;
this->crViewer->Name = "crystalReportViewer1";
this->crViewer->TabIndex = 0;
this->Controls->Add (this->crViewer);

//This attaches the form load event to the function.
this->Load += new System::EventHandler (this, ViewForm_Load);

void ViewForm_Load(System::Object* sender, System::EventArgs* e)
String* crParamVal;
//Instantiate the report and load the report.
crReportDocument = new ReportDocument ();
("C:\\Crystal\\crnet\\cppnet_win_paramengine\\CRPa rams.rpt");

//Get the collection of parameters from the report
crParameterFieldDefinitions =

//Access the specified parameter from the collection
crParameterFieldDefinition =
crParameterFieldDefinitions->Item ["Country"];

//Get the current values from the parameter field. At
this point
//there are zero values set.
crParameterValues = crParameterFieldDefinition->CurrentValues;

//Set the current values for the parameter field
crParamVal = "Canada";
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue->Value = crParamVal; //1st
current value

//Add the first current value for the parameter field

//Since this parameter allows multiple values, the
discrete value
//object needs to be reset. Destroy the previous instance
and create
//a new instance.
crParameterDiscreteValue = 0;
crParameterDiscreteValue = new ParameterDiscreteValue();

//Add the second current value for the parameter field
crParamVal = "USA";
crParameterDiscreteValue->Value = crParamVal; //2nd current value

//All current parameter values must be applied for the
parameter field.

//Set the viewer to the report object to be previewed.
crViewer->ReportSource = crReportDocument;

// This is the entry point for this application
#ifdef _UNICODE
int wmain(void)
int main(void)
Application::Run(new ViewForm());
return 0;
Nov 17 '05 #1
0 3529

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: rAGHU | last post by:
Hi, In my ASP.NET web application project we need to design crystal reports with Crystal Reports version 8.5 enterpraise edition(Please Note:It is not the Crystal Reports that comes with...
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
by: Dr. Indera | last post by:
hello, much to my surprise, the version of crystal that comes with visual studio.net 2003 does not have a report preview window. i found out that i have to build a form in visual basic.net and...
by: BStorm | last post by:
I have a transaction log file where the DataSet table's Description column is actually delimited into "subcolumns" based upon the transaction id. I would like to parse these into separate fields...
by: Stu | last post by:
Hi there, I am trying to set up a Crystal Report with the following tables: Customer Info: -Name -Address -CustomerID Orders:
by: Rich Moser | last post by:
My organization is in the midst of making a reporting tool decision. On the table are Crystal and the reporting functionality in Access. - Report distribution is not a factor - it's all local -...
by: Robert Schuldenfrei | last post by:
Hello NG, After a bit of a wait my bookstore, SoftPro of Waltham, MA, got in the Brian Bischof book: Crystal Reports .NET Programming. I have read a few books on CR, but I am very new to it,...
by: John R. Dougherty | last post by:
I have developed an application with VB.NET, which includes the Crystal Reports (Visual Studio .NET 2003 edition) controls. I can run the application on my PC and it does work fine, but on any...
by: VMI | last post by:
I know this may not be the best NG for this, but I feel you guys know more about this than any of the other NGs. I need to build several simple reports (over 50 of them and they get their data...
by: AAJ | last post by:
Hi all I use a 3 tier approach for my project, and all comms to the database is via a BLL layer. This works fine. I have been lazy in the past, and when reporting via crystal I have created...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.