473,396 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

Hi,

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

http://support.crystaldecisions.com/...lesAndUpdates/
cppnet_win_subreport_basic.exe.asp

(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,

Dean

------------------------------------------------
//********************************************
//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
field
// 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
{
private:
//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:
//Public constructor
ViewForm()
{
InitForm() ;
}
//destructor
~ViewForm()
{
this->Dispose() ;
}

void InitForm()
//This function initializes the form and adds the viewer to the
form.
{
// 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 ();
crReportDocument->Load
("C:\\Crystal\\crnet\\cppnet_win_paramengine\\CRPa rams.rpt");

//Get the collection of parameters from the report
crParameterFieldDefinitions =
crReportDocument->DataDefinition->ParameterFields;

//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
crParameterValues->Add(crParameterDiscreteValue);

//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
crParameterValues->Add(crParameterDiscreteValue);

//All current parameter values must be applied for the
parameter field.
crParameterFieldDefinition->ApplyCurrentValues(crParameterValues);

//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)
#else
int main(void)
#endif
{
Application::Run(new ViewForm());
return 0;
};
Nov 17 '05 #1
0 3608

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

Similar topics

1
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...
13
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...
6
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...
5
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...
2
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:
4
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 -...
9
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,...
4
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...
3
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...
3
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.