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

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 3529

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: 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...
0
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...
1
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...
2
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...
0
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...
0
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...
1
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...
0
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...
0
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.