|
 |
|
ปัญหาการสร้าง Crystal Report มีการร้องขอการเชื่อมต่อฐานข้อมูล |
|
 |
|
|
 |
 |
|
ตอนนี้ดึงข้อมูลได้แล้วครับ แต่เมื่อกดปริ้นมันไม่ทำอะไรเลย
Code (C#)
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
loadReport();
}
protected void loadReport()
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("CrystalReport1.rpt"));
rpt.SetDatabaseLogon("sa", "1234", "localhost", "Work");
rpt.SetParameterValue("Emp_ID", txtEmp_ID.Text);
rpt.SetParameterValue("Year_Work", DropYear.SelectedValue);
rpt.SetParameterValue("Month_Work", DropMonth.SelectedValue);
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
//rpt.RecordSelectionFormula="{tb.colum}='"+DropYear.SelectedValue+"'";
//CrystalReportViewer1.RefreshReport();
}
จากโค้ดด้านบนเมื่อกดปุ่มกดค้นใน toolbar จะปรากฎการเตือนดังรูปนี้ครับ

ผมลองแก้ให้มันเรียก loadreport() ในตอน Page load มันกดปริ้นได้ครับ แต่เมื่อกดปริ้นหรือยกเลิกการปริ้น มันไม่สามารถทำอย่างอื่นได้อีก
นอกจากใช้งานใน toolbar ของ Crystal report
Code (C#)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
else if (IsPostBack)
{
loadReport();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
loadReport();
}
protected void loadReport()
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("CrystalReport1.rpt"));
rpt.SetDatabaseLogon("sa", "1234", "localhost", "Work");
rpt.SetParameterValue("Emp_ID", txtEmp_ID.Text);
rpt.SetParameterValue("Year_Work", DropYear.SelectedValue);
rpt.SetParameterValue("Month_Work", DropMonth.SelectedValue);
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
//rpt.RecordSelectionFormula="{tb.colum}='"+DropYear.SelectedValue+"'";
//CrystalReportViewer1.RefreshReport();
}
พอมีทางแก้บ้างไหมครับ
** ผมไม่เข้าใจจริงๆ ว่าทำไมเมื่อ load page ใหม่ ดูเหมือนว่ามันจะไม่มีรายงานนั้นอีกหากผมไม่เรียก loadReport() ซ้ำ
** อีกอย่างมีคำสั่งอะไรที่พอจะควบคุมปุ่ม ปริ้น ใน toolbar ของ crystal report ได้บ้างมั้ย
ใครที่พอจะช่วยได้ช่วยหน่อยน่ะครับ ผมติดเรื่องออกรายงานมาเกือบ อาทิตย์แล้วครับ
|
ประวัติการแก้ไข 2012-06-28 15:08:10 2012-06-28 15:16:58
 |
 |
 |
 |
Date :
2012-06-28 15:07:19 |
By :
KuNgbAng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|