473,769 Members | 3,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_subr eport_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::Ru n(new ViewForm());

at the end of the file with:
Application::Ru n(new ViewForm());
Application::Ru n(new ViewForm());
Application::Ru n(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 <CrystalDecisio ns.Shared.dll>
#using <CrystalDecisio ns.Windows.Form s.dll>
#using <CrystalDecisio ns.CrystalRepor ts.Engine.dll>

using namespace System;
using namespace System::Windows ::Forms;
using namespace CrystalDecision s::Shared;
using namespace CrystalDecision s::CrystalRepor ts::Engine;
using namespace CrystalDecision s::Windows::For ms;

// 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.

CrystalDecision s::Windows::For ms::CrystalRepo rtViewer* crViewer;
ReportDocument* crReportDocumen t;
ParameterFieldD efinitions* crParameterFiel dDefinitions;
ParameterFieldD efinition* crParameterFiel dDefinition;
ParameterValues * crParameterValu es;
ParameterDiscre teValue* crParameterDisc reteValue;

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
CrystalDecision s::Windows::For ms::CrystalRepo rtViewer();
this->crViewer->ActiveViewInde x = -1;
this->crViewer->Dock = System::Windows ::Forms::DockSt yle::Fill;
this->crViewer->Name = "crystalReportV iewer1";
this->crViewer->TabIndex = 0;
this->Controls->Add (this->crViewer);

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

void ViewForm_Load(S ystem::Object* sender, System::EventAr gs* e)
{
String* crParamVal;
//Instantiate the report and load the report.
crReportDocumen t = new ReportDocument ();
crReportDocumen t->Load
("C:\\Crystal\\ crnet\\cppnet_w in_paramengine\ \CRParams.rpt") ;

//Get the collection of parameters from the report
crParameterFiel dDefinitions =
crReportDocumen t->DataDefiniti on->ParameterField s;

//Access the specified parameter from the collection
crParameterFiel dDefinition =
crParameterFiel dDefinitions->Item ["Country"];

//Get the current values from the parameter field. At
this point
//there are zero values set.
crParameterValu es = crParameterFiel dDefinition->CurrentValue s;

//Set the current values for the parameter field
crParamVal = "Canada";
crParameterDisc reteValue = new ParameterDiscre teValue();
crParameterDisc reteValue->Value = crParamVal; //1st
current value

//Add the first current value for the parameter field
crParameterValu es->Add(crParamete rDiscreteValue) ;

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

//Add the second current value for the parameter field
crParamVal = "USA";
crParameterDisc reteValue->Value = crParamVal; //2nd current value
crParameterValu es->Add(crParamete rDiscreteValue) ;

//All current parameter values must be applied for the
parameter field.
crParameterFiel dDefinition->ApplyCurrentVa lues(crParamete rValues);

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

// This is the entry point for this application
#ifdef _UNICODE
int wmain(void)
#else
int main(void)
#endif
{
Application::Ru n(new ViewForm());
return 0;
};
Nov 17 '05 #1
0 3638

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

Similar topics

1
5995
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 VisualStudio.NET). Also the Crsyatl Report software 8.5 version will not be installed in the IIS web server which is hosting my ASP.NET web application. It will be installed in a different server which has .net and IIS 5.0.
13
15179
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 designer it shows up very fast. When the report is printed from my application it takes about ten times as long to get the report to appear. When printing straight from the Crystal Reports
6
4122
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 use the crystal view object to be able to view forms. the form works fine for me, so i created a .exe of the form and emailed it to a friend because i thought they would be able to use the form/.exe without having visual studio.net installed. that...
5
3026
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 for reporting purposes and am wondering if anyone knows if this is easily accomplished using the .NET version of Crystal Reports? For example, the description column may be reporting on a dataentry error as follows: TXNCODE: 1010001
2
6368
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
11425
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 - Training time is a factor since we have to create a boatload of reports in a short time - The ability for users to modify report formats and data content is required - Cost is a factor - no one wants to spend too much money
9
7152
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, C#, and SQL. The book is excellent. Undaunted, I have plowed into a conversion of my old COBOL ERP system, MCS-3, into C#. I have quite a bit of Inventory Control done and working. For reports I am trying to use CR. I have a half a dozen of them...
4
3776
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 other PC it throws an error message once the user tries to view an existing Crystal Report file. How can I use my application to view Crystal Reports from other PCs? Do I have to include the .RPT files in the VB.NET project? What about when .RPT...
3
8924
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 from sql server) and I was wondering whish of these is the better tool .. We're still not sure if they'll be loaded from an existing VB6 application or if I'll have to make a separate module for them (in .Net). In general, which is the better tool?...
3
1924
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 a connection directly to the database view and recreated the parameters used on the web pages to display identical information, but in crystal. This has left me with two problems
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10000
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.