473,516 Members | 3,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crystal parameters

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 working
directly off of the SQL Server database. In order to do record (OK, I am an
old COBOL hand! Read row.) selection I have a field (OK, column) called
im_planner_code in the database. Using the default parameter ?plannerCode I
am able to select all rows with im_planner_code = "A". I would like to
develop my own parameter dialog box. To start I have invoked the code
listed below at the load event of Form1303. It compiles clean, but has an
execution error at the highlighted line. I would of course like to know
what my problem is, but beyond that I need to know how to debug CR execution
errors.

Is there a good newsgroup for CR under .NET? I currently read:
Microsoft.public.dotnet.languages.csharp. Thank you in advance.

Cheers,

Bob

Robert Schuldenfrei

S. I. Inc.

32 Ridley Road

Dedham, MA 02026

(781) 329-4828

bo*@s-i-inc.com

www.s-i-inc.com

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

namespace Reports

{

/// <summary>

/// Summary description for Form1303.

/// </summary>

public class Form1303 : System.Windows.Forms.Form

{

private CrystalDecisions.Windows.Forms.CrystalReportViewer
crystalReportViewer1;

private Reports.rpt1303 rpt13031;

private ParameterDiscreteValue parameterDiscreteValue;
//used for parameter passing

private ParameterValues parameterValues;

private ParameterFieldDefinition parameterFieldDefinition;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public Form1303()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after
InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.crystalReportViewer1 = new
CrystalDecisions.Windows.Forms.CrystalReportViewer ();

this.rpt13031 = new Reports.rpt1303();

this.SuspendLayout();

//

// crystalReportViewer1

//

this.crystalReportViewer1.ActiveViewIndex = -1;

this.crystalReportViewer1.Dock =
System.Windows.Forms.DockStyle.Fill;

this.crystalReportViewer1.Location = new
System.Drawing.Point(0, 0);

this.crystalReportViewer1.Name = "crystalReportViewer1";

this.crystalReportViewer1.ReportSource = this.rpt13031;

this.crystalReportViewer1.Size = new
System.Drawing.Size(892, 746);

this.crystalReportViewer1.TabIndex = 0;

//

// rpt13031

//

this.rpt13031.PrintOptions.PaperOrientation =
CrystalDecisions.Shared.PaperOrientation.Landscape ;

this.rpt13031.PrintOptions.PaperSize =
CrystalDecisions.Shared.PaperSize.DefaultPaperSize ;

this.rpt13031.PrintOptions.PaperSource =
CrystalDecisions.Shared.PaperSource.Upper;

this.rpt13031.PrintOptions.PrinterDuplex =
CrystalDecisions.Shared.PrinterDuplex.Default;

//

// Form1303

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(892, 746);

this.Controls.Add(this.crystalReportViewer1);

this.Name = "Form1303";

this.Text = "Form1303";

this.WindowState =
System.Windows.Forms.FormWindowState.Maximized;

this.Load += new System.EventHandler(this.Form1303_Load);

this.ResumeLayout(false);

}

#endregion

private void Form1303_Load(object sender, System.EventArgs e)

{

this.crystalReportViewer1.Zoom(75);

//Use the ReportDocument object to create plannerCode &
productCode parameters

//note: my ReportDocument is called rpt13031 not
CrystalReport1

rpt1303 myReport = new rpt1303();

//Step 1: property field to modify - ERROR: Invalid field
name.

parameterFieldDefinition =
myReport.DataDefinition.ParameterFields["?plannerCode"];

//Step 2: instantiate parameterValues collection

parameterValues = new ParameterValues();

//Step 3: instantiate a parameterValue

parameterDiscreteValue = new ParameterDiscreteValue();

//Step 4: set Value property

parameterDiscreteValue.Value = "A"; //will get this
from user

//Step 5: use Add() method to add to collection

parameterValues.Add(parameterDiscreteValue);

//Step 6: other parameters go here (productCode)

//Step 7: assign collection to parameter field
parameterFieldDefinition.ApplyCurrentValues(parame terValues);

//Step 8: preview report

crystalReportViewer1.ReportSource = myReport;

}

}

}


Nov 16 '05 #1
9 7138
Hi NG,

I changed my approach and made progress. The code below now uses the
CrystalReportViewer classes. It works except that:

1/ It displays the default parameter screen in spite of the fact that I am
providing my own parameters. It then flashes the correct result of the
standard parameter screen before running my parameter .Value = "A"
correctly. Is the Load event the correct placement for parameter
over-rides?

2/ The final report does not set the Zoom(75) property but reverts back to
100%.

TIA

Bob
bo*@s-i-inc.com

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

namespace Reports

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class Form1301 : System.Windows.Forms.Form

{

private CrystalDecisions.Windows.Forms.CrystalReportViewer
crystalReportViewer1;

private Reports.rpt1301 rpt13011;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

private ParameterDiscreteValue parameterDiscreteValue; //used for parameter
passing

private ParameterFields parameterFields;

private ParameterField parameterField; //note: removed I

public Form1301()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.crystalReportViewer1 = new
CrystalDecisions.Windows.Forms.CrystalReportViewer ();

this.rpt13011 = new Reports.rpt1301();

this.SuspendLayout();

//

// crystalReportViewer1

//

this.crystalReportViewer1.ActiveViewIndex = -1;

this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;

this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);

this.crystalReportViewer1.Name = "crystalReportViewer1";

this.crystalReportViewer1.ReportSource = this.rpt13011;

this.crystalReportViewer1.Size = new System.Drawing.Size(696, 374);

this.crystalReportViewer1.TabIndex = 0;

//

// rpt13011

//

this.rpt13011.PrintOptions.PaperOrientation =
CrystalDecisions.Shared.PaperOrientation.Landscape ;

this.rpt13011.PrintOptions.PaperSize =
CrystalDecisions.Shared.PaperSize.DefaultPaperSize ;

this.rpt13011.PrintOptions.PaperSource =
CrystalDecisions.Shared.PaperSource.Upper;

this.rpt13011.PrintOptions.PrinterDuplex =
CrystalDecisions.Shared.PrinterDuplex.Default;

//

// Form1301

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(696, 374);

this.Controls.Add(this.crystalReportViewer1);

this.Name = "Form1301";

this.Text = "Crystal Reports - 1301";

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.Load += new System.EventHandler(this.Form1301_Load);

this.ResumeLayout(false);

}

#endregion

private void Form1301_Load(object sender, System.EventArgs e)

{

this.crystalReportViewer1.Zoom(75);

//Use the viewer object to create plannerCode & productCode parameters

rpt1301 myReport = new rpt1301();

//Step 1: assign report object to viewer

crystalReportViewer1.ReportSource = myReport;

//Step 2: reference parameterFields collection

parameterFields = crystalReportViewer1.ParameterFieldInfo;

//Step 3: reference the parameterField

//parameterField = new ParameterField();

//parameterField.ParameterFieldName = "plannerCode";

parameterField = parameterFields["plannerCode"];

//Step 4: create a parameterValue object

parameterDiscreteValue = new ParameterDiscreteValue();

//Step 5: assign a value to the object

parameterDiscreteValue.Value = "A";

//Step 6: add the parameterValue object to the CurrentValues collection

parameterField.CurrentValues.Add(parameterDiscrete Value);

//MessageBox.Show("In load event.", "Info");

}

}

}
Nov 16 '05 #2
Hi Robert,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you have two questions. The first is
that there is something wrong with the parameter screen. The second is zoom
is not working properly. If there is any misunderstanding, please feel free
to let me know.

I'm not quite familiar with Crystal Report. But based on the code you have
provided, I recommend you to put the line of code
this.crystalReportViewer1.Zoom(75); after setting the report source. (Try
to move this line to the bottom of Form_Load.) Because setting the report
source might refresh the view, which causes Zoom not working properly.

I'm not quite sure why parameter issue happens. If you could send me a
repro with whole project, I will try to debug it. Thank you!

Since Crystal Report is a third-party product by Business Objects,
currently we have no newsgroup for Crystal Report discussion. Besides
posting here, you can also check Business Objects support website for help.
Here is the link:

http://support.businessobjects.com/

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3
Hi Kevin and NG,

Once again thank you for taking time out to address my problems. Before I
pack up the project and send it to you I would like to know if I am going
off in the right direction. First, and most important, is Crystal Reports
(CR) the right tool for printing reports? I have well over 100 reports in
my application and I would like to use the best tool for the job.

Second, if CR is the right tool, am I using it correctly? Because it was
easy to do, I started using CR directly against the SQL database. This
seems to be called the "Pull" technique by books on CR. For 90% of my
reports this will work. For the last 10% I will have to reformat and/or
restructure the data in a C# program. At this point I could either create a
temporary SQL table and print the report use the same "Pull" technique I
have been using on the 90%, or send it to CR using the "Push" technique. I
have not yet learned the "Push" technique. A good example of such a report
in my ERP application would be an indented Bill of Materials report. This
is a report that follows a tree structure rather than a simple listing of
records (rows) in a table.

Third, moving the .Zoom(75) property to the end of the report made the
message that appears in the bottom of the window say 75%, but the view was
at 100%. I can use the icons at the top of the window to force it to 75%.
Other properties now set by code take effect correctly such as the
..DisplayGroupTree property.
crystalReportViewer1.DisplayGroupTree = false;
crystalReportViewer1.Zoom(75);

Finally, is the report load event the proper place for this code?

As ever, thank you for your help,

Cheers,

Bob

--
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA 02026
bo*@s-i-inc.com
781/329-4828

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Oj*************@cpmsftngxa06.phx.gbl...
Hi Robert,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you have two questions. The first is
that there is something wrong with the parameter screen. The second is zoom is not working properly. If there is any misunderstanding, please feel free to let me know.

I'm not quite familiar with Crystal Report. But based on the code you have
provided, I recommend you to put the line of code
this.crystalReportViewer1.Zoom(75); after setting the report source. (Try
to move this line to the bottom of Form_Load.) Because setting the report
source might refresh the view, which causes Zoom not working properly.

I'm not quite sure why parameter issue happens. If you could send me a
repro with whole project, I will try to debug it. Thank you!

Since Crystal Report is a third-party product by Business Objects,
currently we have no newsgroup for Crystal Report discussion. Besides
posting here, you can also check Business Objects support website for help. Here is the link:

http://support.businessobjects.com/

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4
Hi Robert,

1. Yes, I think CR is a good tool for use to generate reports both on
winform and web form.

For 2,3,4 I'm not quite familiar about this. I can just take a look at your
code and try my best to help. Since it is not Crystal Report is a 3rd-party
product, it is not supported by Microsoft. If you can't get a satifying
answer here, I think you can also have a try in the Crystal Report support
website.

http://support.businessobjects.com/

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5
Hi Kevin,

Thanks a lot. OK, I will keep at it using CR as my principal report writer.
If by this time tomorrow, I do not get an obvious answer, I will send you my
project. Understand that there are a number of working reports in the
project such that the folder that contains the problem class is not the only
thing that will be sent. There is 256 KB of uncompressed files in the
source folder. I have gone through the BusinessObjects web site and it has
not been all that helpful.

Cheers,

Bob
--
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA 02026
bo*@s-i-inc.com
781/329-4828
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:9O**************@cpmsftngxa06.phx.gbl...
Hi Robert,

1. Yes, I think CR is a good tool for use to generate reports both on
winform and web form.

For 2,3,4 I'm not quite familiar about this. I can just take a look at your code and try my best to help. Since it is not Crystal Report is a 3rd-party product, it is not supported by Microsoft. If you can't get a satifying
answer here, I think you can also have a try in the Crystal Report support
website.

http://support.businessobjects.com/

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6
Hi Bob,

I will wait for your project and try my best to help. However, my knowlege
in Crystal Report is limited. So please excuse, if I can't help much.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #7
Hi NG and Kevin,

Here is my Reports folder. (NG: I sent this directly to Kevin, but I did
not want to gum up the NG with a ZIP file) The report with the parameter
passing is rpt1301.rpt. If you try to run the report you are going to need
the SQL Server data. Let me know if you need this capability. If you do
need this capability give me instructions on how to make a copy of the SQL
data. I am using the MSDE version of SQL right now. Thank you for your
help.

Cheers,

Bob
--
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA 02026
bo*@s-i-inc.com
781/329-4828

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:rh***************@cpmsftngxa06.phx.gbl...
Hi Bob,

I will wait for your project and try my best to help. However, my knowlege
in Crystal Report is limited. So please excuse, if I can't help much.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #8
Hi Bob,

I tried to check how that error happens. But based on the error message
ERROR: Invalid field name, I think there might be something wrong with the
field name "plannerCode". Please check if this field is in the parameter
collection.

I'm sorry but debugging Crystal Report is really beyond my ability. I think
you will get more information and advice from
http://support.businessobjects.com/

Sorry that I didn't provide much help on this issue.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #9
Thanks anyway Kevin,

I am not getting an error message. In fact my code executes correctly
except for the "extra" dialog box for the standard parameter.

Cheers,

Bob
--
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA 02026
bo*@s-i-inc.com
781/329-4828
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Hz**************@cpmsftngxa06.phx.gbl...
Hi Bob,

I tried to check how that error happens. But based on the error message
ERROR: Invalid field name, I think there might be something wrong with the
field name "plannerCode". Please check if this field is in the parameter
collection.

I'm sorry but debugging Crystal Report is really beyond my ability. I think you will get more information and advice from
http://support.businessobjects.com/

Sorry that I didn't provide much help on this issue.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #10

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

Similar topics

0
1500
by: murl | last post by:
I have built a crystal report using crystal9.0 that is linked to a stored procedure built in sql2k, which requires 2 parameters beginningdate(smalldatetime),and endingdate(smalldatetime). When the parameters are met in crystal the report shows up correctly with no problems, but when the report is displayed using the crsyatal report viewer in...
0
4888
by: Craig Faulkner | last post by:
I have been fighting through my first crystal report in VS2003.NET and have made some headway. Here is what I've done: 1. Created a crystal report in VS2003 from a SQL stored procedure with parameters through the GUI. 2. Finally got past the logon failure error to display the report using the viewer. I assume that default parameters are...
0
2050
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the data into a comboBox. One thing I noticed, however, is that this method shows me both the parameters used by the main report and parameters used by...
1
2516
by: raf_z | last post by:
Hi, I'm running a website with Asp.NET, and on one of the pages i have a crystal report with 3 user-populated parameters. However, not all params might be selected. Example: Parameters: 1. EmployeeID 2. First Name 3. Last Name
19
3848
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set ReuseParameterValuesOnRefresh="True" in a viewer, but it still doesn't work. Did anyone run into this problem. What's the solution? Please help. Thank you
12
10365
by: Bill Nguyen | last post by:
What's the VB syntax to run the CR report using the following SP? I use CrystalreportViewer and ReportDocument. Thanks Bill Here's the SP in SQLserver 2K: CREATE proc mysp_ReportSubmission @salesdate as varchar(20),
0
3895
by: bonita | last post by:
In my ASP.NET page, I have 2 checkboxes for users to choose which crystal report they want to display. These two reports use different tables. If report1 has been choosen and displayed in the crystal report, then I cannot check another checkbox to display report2 afterwards. If I close the website and open again, I can choose report2 and...
0
1703
by: Linda W. | last post by:
Hi, I would appreciate any insight into the following issue.. I have an asp.net application with crystal reports being displayed.. All works fine from my IDE & I am trying to move the app to a test server. The report parameters are input on the first aspx page and I store them in the Session object & use a Server.Transfer() to get to the...
7
6691
by: Jlo | last post by:
Hi, I have a c# winforms application. When I call the report file, it shows me all the records in the table. How can I make it to call only a particular range. i have the following code Viewer1.ReportSource = Application.StartupPath + "//Label.rpt"; How can I assign it a dataset which have the data of a particular range.
1
8119
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings file and itself into the exe. You would probably want a tool for this bit which could be in the zip too. So the app isnt single exe when running but...
0
7273
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...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7574
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7547
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...
0
5712
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...
1
5106
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...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
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...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.