Sample Crystal Report Generation
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class SimpleCrystal2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Hospitals_dbo obj = new Hospitals_dbo(false);
//SqlConnection con = new SqlConnection("Server='10.0.0.10';Initial Catalog='sample.DB';user id='user';password='password'");
//con.Open();
ReportDocument rptdoc = new ReportDocument();
DataSetCrystal ds = new DataSetCrystal(); //XSD dataset Sample data Table from the command
DataTable dt = new DataTable();
DataSet d = new DataSet();
dt.TableName = "Crystal Report Example";
string cmd = "Select PrescriptionID,MedicineName,Dosage,VisitID from Mw_Prescriptions where PrescriptionID='" + TextBox1.Text + "'";
d = obj.ExecuteDataSet(cmd);
dt = d.Tables[0];
ds.Tables[0].Merge(dt);
rptdoc.Load(Server.MapPath("SimpleCrystal2.rpt"));
rptdoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptdoc;
}
}
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class SimpleCrystal2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Hospitals_dbo obj = new Hospitals_dbo(false);
//SqlConnection con = new SqlConnection("Server='10.0.0.10';Initial Catalog='sample.DB';user id='user';password='password'");
//con.Open();
ReportDocument rptdoc = new ReportDocument();
DataSetCrystal ds = new DataSetCrystal(); //XSD dataset Sample data Table from the command
DataTable dt = new DataTable();
DataSet d = new DataSet();
dt.TableName = "Crystal Report Example";
string cmd = "Select PrescriptionID,MedicineName,Dosage,VisitID from Mw_Prescriptions where PrescriptionID='" + TextBox1.Text + "'";
d = obj.ExecuteDataSet(cmd);
dt = d.Tables[0];
ds.Tables[0].Merge(dt);
rptdoc.Load(Server.MapPath("SimpleCrystal2.rpt"));
rptdoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptdoc;
}
}
Comments
Post a Comment