Hi. Im currently doing my thesis and im suppose to generate monthly reports about our sales. Im having a hard time filtering the date. Yung gusto ko po kasi mangyari is that, may 2 textboxes. yung isang textbox is FROM: (date), the other one is TO:(date).. then when i click the "generate" button, it will show the report. I have no idea on how to do it. I have very basic knowledge about the language and im not that good and experienced in programming. Any kind of help will do. Thanks!
any specific problem? Saan ka ba may problema?
all i get is "missing parameter values".. here is my code.. I dont know how to replace the codes that are commented out..
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using CrystalDecisions.CrystalReports.Engine;using CrystalDecisions.Shared;public partial class test : System.Web.UI.Page{ string connstring = ConfigurationManager.ConnectionStrings["JDIConnectionString"].ConnectionString; protected void Page_Load(object sender, EventArgs e) { } private void ConfigureCrystalReports() { string reportPath = Server.MapPath("ProductByCategory.rpt"); crystalreport.ReportSource = reportPath; string StartDate; string EndDate; //ParameterFields parameterFields = crystalreport.ParameterFieldInfo; ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.DatabaseName = "JDI"; connectionInfo.ServerName = "JOSHMC/SQLEXPRESS"; connectionInfo.IntegratedSecurity = true; //if (!IsPostBack) //{ // Session["StartDate"] = StartDate; // Session["EndDate"] = EndDate; //} //else //{ // StartDate = Session["StartDate"].ToString(); // EndDate = Session["EndDate"].ToString(); //} } private void Page_Init(object sender, EventArgs e) { ConfigureCrystalReports(); } private void SetDBLogonForReport(ConnectionInfo connectionInfo) { TableLogOnInfos tableLogOnInfos = crystalreport.LogOnInfo; foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos) { tableLogOnInfo.ConnectionInfo = connectionInfo; } SetDBLogonForReport(connectionInfo); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { txtboxFROM.Text = Calendar1.SelectedDate.ToShortDateString(); txtboxTO.Text = Calendar1.SelectedDate.ToShortDateString(); } protected void btnGenerate_Click(object sender, EventArgs e) { crystalreport.Visible = true; txtboxFROM.Text = Calendar1.SelectedDate.ToShortDateString(); txtboxTO.Text = Calendar1.SelectedDate.ToShortDateString(); //ArrayList arrayList = new ArrayList(); //foreach (ListItem item in supplierlist.Items) //{ // if (item.Selected) // { // arrayList.Add(item.Value); // } //} //Session["arrayList"] = arrayList; Session["StartDate"] = txtboxFROM.Text; Session["EndDate"] = txtboxTO.Text; ConfigureCrystalReports(); }}
I have not explored Crystal Report bundled with the latest Visual Studio but using VS 2003 .NET Framework 1.1 this is how we assign a value to Report Parameter.
report.SetParameterValue("ParamName", CType(ParamValue, DateTime))
the above code assumes that your ParamValue is in Type String, kung ang ParamValue mo is in Date na you can use the code below.
report.SetParameterValue("ParamName", ParamValue)
I dont know how to set my parameters and how to configure the select expert at the field report explorer in the crystal reports. Is there any way i can manually code my select expert?
..you may want to try to pass your dates as parameters upon retrieving the records from your database so that the dataset you're going to LOAD to the reportdocument is already filtered..