R
Robert Schuldenfrei
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
(e-mail address removed)
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(parameterValues);
//Step 8: preview report
crystalReportViewer1.ReportSource = myReport;
}
}
}
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
(e-mail address removed)
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(parameterValues);
//Step 8: preview report
crystalReportViewer1.ReportSource = myReport;
}
}
}