VS 2010 สอบถาม Crystal Report Error ไม่ยอมโชว์หน้าเว็บครับ
เป็นปัยหาที่ Connection ครับ
Code (C#)
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
cryRpt.Load(MapPath("CrystalReport.rpt"));
crConnectionInfo.ServerName = "ICELand";
crConnectionInfo.DatabaseName = "MiniOPT";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "121212";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
ปัญหา Crystal Report การส่งค่า Username/Password บน SQL Server 2005/2008 กับ ASP.NET
Date :
2015-11-19 13:21:46
By :
mr.win
Failed to open the connection. Failed to open the connection. Details: [Database Vendor Code: 53 ] Failed to open the connection. Details: [Database Vendor Code: 53 ] Failed to open the connection. report4 {A089B484-47D7-483D-B7DA-305F521853A1}.rpt
Error อันนี้แทนแล้วครับ
Date :
2015-11-19 16:50:53
By :
toey1
มันเป็นที่ Connection ครับ คุณเชื่อม Database ไปที่ไหนครับ
Date :
2015-11-19 17:01:35
By :
mr.win
SQL Server 2008 ครับ
ของเดิมครับ
Code (C#)
void ConfigureCrystalReports()
{
CrystalDecisions.CrystalReports.Engine.ReportDocument rptReport
= new CrystalDecisions.CrystalReports.Engine.ReportDocument();
rptReport.Load(Server.MapPath("report4.rpt"));
rptReport.SetDatabaseLogon("sa", "pa2ssword");
CrystalReportViewer1.ReportSource = rptReport;
//rptReport.SetParameterValue("startdate", Session["startdate"].ToString());
//rptReport.SetParameterValue("enddate", Session["enddate"].ToString());
Session["ReportSource1"] = rptReport;
}
ของใหม่ที่แก้ครับ
Code (C#)
void ConfigureCrystalReports()
{
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
cryRpt.Load(MapPath("report4.rpt"));
crConnectionInfo.ServerName = "ADMIN-PC";
crConnectionInfo.DatabaseName = "Helpdesk";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "pa2ssword";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
}
Date :
2015-11-19 23:17:10
By :
toey1
Code (C#)
strOrderID = Request.QueryString["OrderID"]);
rpt = new ReportDocument();
rpt.Load(Server.MapPath("../Rpt/myReport.rpt"));
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "locahost";
crConnectionInfo.DatabaseName = "mydatabase";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "";
CrTables = rpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
rpt.SetParameterValue("OrderID", strOrderID);
this.rptCrystal.ReportSource = rpt;
rptCrystal.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
Code นี้เป็นตัวที่ผมใช้อยู่ปัจจุบันเลยครับ ใช้ดีไม่มีปัญหา
Date :
2015-11-20 10:33:22
By :
mr.win
Code เต็ม ๆ
Code (C#)
public partial class myReport : Sytemm.Web.UI
{
private string strOrderID = string.Empty;
private ReportDocument rpt;
protected void Page_Load(object sender, EventArgs e)
{
strOrderID = Request.QueryString["OrderID"]);
rpt = new ReportDocument();
rpt.Load(Server.MapPath("../Rpt/myReport.rpt"));
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "locahost";
crConnectionInfo.DatabaseName = "mydatabase";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "";
CrTables = rpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
rpt.SetParameterValue("OrderID", strOrderID);
this.rptCrystal.ReportSource = rpt;
rptCrystal.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
}
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
try
{
if (rpt != null)
{
rpt.Close();
rpt.Dispose();
GC.Collect();
}
}
catch (Exception ex)
{
// Exception
}
}
protected void rptCrystal_Unload(object sender, EventArgs e)
{
try
{
if (rpt != null)
{
rpt.Close();
rpt.Dispose();
GC.Collect();
}
}
catch (Exception ex)
{
// Exception
}
}
}
Date :
2015-11-20 10:35:29
By :
mr.win
ตอนนี้ไม่มี Error ครับ แต่เอาไปรันที่ IIS7 มันดันเป็นหน้าเว็บเปล่าๆครับ แต่รันผ่าน VS2010ขึ้นมา ยังไงดีครับ
Date :
2015-11-21 15:30:46
By :
toey1
เอาขึ้น IIS7
อันนี้ run ผ่านโปรแกรม VS2010
ต้องทำไรดีล่ะครับทีนี้
รบกวนด้วยครับ
Date :
2015-11-21 15:42:34
By :
toey1
ตอนนี้ report ขึ้นมาแล้วครับ แต่ติดตรงที่พอจะ Next Page ขึ้นแบบนี้เลยครับ
Code (C#)
rpt = new ReportDocument();
rpt.Load(Server.MapPath("report4.rpt"));
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
crConnectionInfo.ServerName = "TOEY-PC";
crConnectionInfo.DatabaseName = "Helpdesk";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "password";
CrTables = rpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
//ส่ง Parameter ไปยัง Report
rpt.SetParameterValue("startdate", Session["startdate"].ToString());
rpt.SetParameterValue("enddate", Session["enddate"].ToString());
this.CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
Date :
2015-11-21 16:40:12
By :
toey1
รบกวนด้วยครับ
ประวัติการแก้ไข 2015-11-26 15:34:04
Date :
2015-11-23 22:55:50
By :
toey1
Load balance : Server 00