Here's the code of the calling page (Default.aspx):
protected void Button1_Click(object sender, EventArgs e)
{
Context.Items["rptfile"] = @"C:\ASP temp1\Report1.rpt";
Context.Items["brokercode1"] = DropDownList1.SelectedValue;
Context.Items["codate"] = 20500101;
Server.Transfer("Default2.aspx", true);
}
and here's the code of the called page (Default2.aspx):
protected void Page_Load(object sender, EventArgs e)
{
string strcon = "Dsn=Pres1_ver3.5;database=pres;server=Pres1;uid=xxxx;pwd=xxxx";
OdbcConnection con = new OdbcConnection(strcon);
con.Open();
OdbcCommand com = new OdbcCommand("CALL sp_offerprinting(?)", con);
com.CommandType = CommandType.StoredProcedure;
/* OdbcCommand com = new OdbcCommand();
com.CommandType = CommandType.Text;
com.CommandText = "SELECT acno, assured, expiry, blines.name " +
"as name, " +
"offer.code, tsi, tsr, offdate, acdate, " +
"status as status1, approved FROM offer " +
"right join blines on blines.code = offer.code " +
"right join broker on broker.code = offer.code " +
"WHERE tsi <> 0 AND " +
"offdate <= codate AND " +
"offer.code = brokercode1 AND" +
"approved <> space(30) AND status <> 'C' AND " +
"status <> 'M' AND status <> 'D' AND bnderno = ' ' " +
"order by offer.code, blines.name, acno limit 10";
*/
com.Parameters.Add(new OdbcParameter("?brokercode1", OdbcType.Int, 5));
com.Parameters["?brokercode1"].Direction = ParameterDirection.Input;
com.Parameters["?brokercode1"].Value = DropDownList1.SelectedValue;
com.Parameters.Add(new OdbcParameter("?codate", OdbcType.Int, 8));
com.Parameters["?codate"].Direction = ParameterDirection.Input;
com.Parameters["?codate"].Value = TextBox1.Text;
string rptfilename = @"C:\ASP temp1\Report1.rpt";
if (this.Context.Items.Count > 2)
{
rptfilename = this.Context.Items["rptfile"].ToString();
DropDownList1.SelectedValue = this.Context.Items["brokercode1"].ToString();
com.Parameters["?brokercode1"].Value = Convert.ToInt32(this.Context.Items["brokercode1"]);
TextBox1.Text = this.Context.Items["codate"].ToString();
com.Parameters["?codate"].Value = this.Context.Items["codate"].ToString();
}
OdbcDataAdapter da = new OdbcDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = com;
da.Fill(ds, "offer");
CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
myReportDocument.Load(rptfilename);
myReportDocument.SetDataSource(ds);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
con.Close();
}
.. or could anyone present this in an easier coding format (sending 2 or more parameters to a page and crystal report)?
Thank you and God Bless!