Hi Angela,
I think that is something that should work. Can you send me the whole soruce code to call the crystal reports? I am new with ASP.net.
Here is what I found the sample source code for win form written in C#. I don't know why to convert them to VB and don't know where to place the soruce code.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication3
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
//CR Variables
CrystalReport1 crReportDocument;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;
private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
private System.Windows.Forms.Button button1;
// private Form1 Frm; // = new Form1();
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form2(Form1 Frm)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
//Create an instance of the strongly-typed report object
crReportDocument = new CrystalReport1();
//Get the collection of parameters from the report
crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields;
//Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinitions["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
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = Frm.OffID.Text; //"Canada"; //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 = null;
//crParameterDiscreteValue = new ParameterDiscreteValue();
//crParameterDiscreteValue.Value = "USA"; //2nd current value
//Add the second current value for the parameter field
//crParameterValues.Add(crParameterDiscreteValue);
//All current parameter values must be applied for the parameter field.
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
///////////////////////////////////////////////////////////////////
//2nd Parameter
//Get the collection of parameters from the report
//crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields;
//Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinitions["Customer"];
//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
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = Frm.startDate.Text; //"Canada"; //1st current value
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
//crParameterFieldDefinition.ApplyCurrentValues(crParameterValues1);
//Set the viewer to the report object to be previewed.
crystalReportViewer1.ReportSource = crReportDocument;
}
/// <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()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// crystalReportViewer1
//
this.crystalReportViewer1.ActiveViewIndex = -1;
this.crystalReportViewer1.AutoScroll = ((bool)(configurationAppSettings.GetValue("crystalReportViewer1.AutoScroll", typeof(bool))));
this.crystalReportViewer1.Location = new System.Drawing.Point(8, 8);
this.crystalReportViewer1.Name = "crystalReportViewer1";
this.crystalReportViewer1.ReportSource = "D:\\Crystal\\crnet\\csharp_win_paramengine\\CRParams.rpt";
this.crystalReportViewer1.ShowCloseButton = ((bool)(configurationAppSettings.GetValue("crystalReportViewer1.ShowCloseButton", typeof(bool))));
this.crystalReportViewer1.Size = new System.Drawing.Size(704, 392);
this.crystalReportViewer1.TabIndex = 0;
this.crystalReportViewer1.Load += new System.EventHandler(this.crystalReportViewer1_Load);
//
// button1
//
this.button1.Location = new System.Drawing.Point(440, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Exit";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(712, 397);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.crystalReportViewer1});
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void Form2_Load(object sender, System.EventArgs e)
{
//Frm = new Form1();
}
private void crystalReportViewer1_Load(object sender, System.EventArgs e)
{
}
}
}
Thanks.