Step 1 : Create a crystal report with parametes
Step 2: Create a new page with CrystalReportViewer
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="report.aspx.cs" Inherits="report" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" Height="1039px" Width="901px" />
</div>
</form>
</body>
</html>
step 3 : write this code
using CrystalDecisions.CrystalReports.Engine;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class report : System.Web.UI.Page
{
ReportDocument rprt = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
rprt.Load(Server.MapPath("~/CP_PS_Custom_Stock.rpt"));
rprt.SetDatabaseLogon("sa", "$QL$erver1");
rprt.SetParameterValue("ClockNo", Request.QueryString["EmpId"].ToString());
rprt.SetParameterValue("CheckDate", Request.QueryString["CheckDate"].ToString());
rprt.SetParameterValue("TransactionNo", Request.QueryString["Trans"].ToString());
rprt.SetParameterValue("Company", Request.QueryString["ComId"].ToString());
//rprt.SetDataSource(GetData("999269", "16504", 2017));
CrystalReportViewer1.ReportSource = rprt;
}
}
Step 2: Create a new page with CrystalReportViewer
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="report.aspx.cs" Inherits="report" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" Height="1039px" Width="901px" />
</div>
</form>
</body>
</html>
step 3 : write this code
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class report : System.Web.UI.Page
{
ReportDocument rprt = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
rprt.Load(Server.MapPath("~/CP_PS_Custom_Stock.rpt"));
rprt.SetDatabaseLogon("sa", "$QL$erver1");
rprt.SetParameterValue("ClockNo", Request.QueryString["EmpId"].ToString());
rprt.SetParameterValue("CheckDate", Request.QueryString["CheckDate"].ToString());
rprt.SetParameterValue("TransactionNo", Request.QueryString["Trans"].ToString());
rprt.SetParameterValue("Company", Request.QueryString["ComId"].ToString());
//rprt.SetDataSource(GetData("999269", "16504", 2017));
CrystalReportViewer1.ReportSource = rprt;
}
}
No comments:
Post a Comment