Hi sir and ma'am. good day.. I have this asp.net website that generate records of Staff. As you type staff's Id no. in a texbox and click the 'Generate record' button, the page will be redirect to the another page of which the report has to be viewed.
In my first aspx.cs (session.aspx):
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class session : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["compNo"] = TextBox1.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("Default.aspx");
}
}
and in my second page.aspx (Default.aspx):
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["compNo"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
ConnectionInfo con = new ConnectionInfo();
con.ServerName = "myservername";
con.DatabaseName = "My_database";
CrystalReportViewer1.ParameterFieldInfo.Clear();
CrystalReportViewer1.ReportSource = Server.MapPath("report.rpt");
ParameterFields parameter = CrystalReportViewer1.ParameterFieldInfo;
ParameterField staffno = new ParameterField();
staffno.Name = "par_staffno";
ParameterDiscreteValue par_staffno_value = new ParameterDiscreteValue();
par_staffno_value.Value = Label1.Text;
staffno.CurrentValues.Add(par_staffno_value);
parameter.Add(staffno);
foreach (TableLogOnInfo tlf in CrystalReportViewer1.LogOnInfo)
{
tlf.ConnectionInfo = con;
}
}
}
I have my report.rpt which I have already populated with designated fields like:
Staff_No, First_Name, Middle_Name, Last_Name
Also, I have already drag the CrystalReport Viewer from toolbox in my second page.
That's all what I have done. Any thing that I forgot to do, I do not know yet.
I got no errors. But when I run it in the browser, the report does not displayed in the browser and I got this "The parameter is incorrect" text at the end of my browser.
-- I'm using SQL server for my database, Visual Studio 2008 (C#) for the codes and everything..
What I have done wrong sir and ma'am? :)