 |
|
[.NET]
Crystal Report รันบน localhost ไม่ได้ครับ ตอนรันใน VS มันรันได้ปกติ แต่พอ Publish แล้วย้ายเข้าไปไว้ใน inetpub พอกดแสดง Report แล้ว Error Server Error in '/project' Application. |
|
 |
|
|
 |
 |
|
โทษทีครับเมื่อกี้มา
bill_id = Request.QueryString["bill_id"].ToString();
WebApplication1.App_Data.DataSet1TableAdapters.billReportTableAdapter BillReport = new WebApplication1.App_Data.DataSet1TableAdapters.billReportTableAdapter();
DataTable dtBill = BillReport.GetDataBillReport(bill_id);
String path = ConfigurationManager.AppSettings["REPORT_TEMP"].ToString();
String fileName = String.Format("{0}{1}.pdf", path, Guid.NewGuid().ToString());
String reportLocation = Server.MapPath("BillReport.rpt");
CrystalReportSource1.ReportDocument.Load(reportLocation);
CrystalReportSource1.ReportDocument.SetDataSource(dtBill);
CrystalReportSource1.ReportDocument.PrintOptions.PaperSize = PaperSize.PaperA4;
CrystalReportSource1.DataBind();
CrystalReportSource1.ReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fileName);
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=payreqinst.pdf");
Response.WriteFile(fileName);
Response.Flush();
Response.Close();
System.IO.File.Delete(fileName);
|
 |
 |
 |
 |
Date :
2009-06-27 22:23:32 |
By :
hassadin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองดูในโฟร์เดอร์ บน IIS มันไม่มี CR ผมเลยไปก๊อปมาใส่ แล้วลองดู กลายเป็น Error แบบนี้ครับ
Error in File C:\Windows\TEMP\BorrowReport {06DB2B84-79B9-4CC9-A187-9AF9F309A1D0}.rpt:
Access to report file denied. Another program may be using it.
|
 |
 |
 |
 |
Date :
2009-06-27 22:52:37 |
By :
hassadin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่าผมก็ติดปัญหานี้อยู่ครับ รอคำตอบเหมือนกันครับ
|
 |
 |
 |
 |
Date :
2009-07-10 11:37:01 |
By :
Patis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีผู้รู้เลยหรอครับ
|
 |
 |
 |
 |
Date :
2009-07-17 16:28:43 |
By :
hassadin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คืองี้ครับ มันไปติดไอ้ตัว CrystalReportSource ดังนั้น ต้องเขียน แบบนี้ครับ
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
CrystalDecisions.Web.CrystalReportSource CRS = new CrystalDecisions.Web.CrystalReportSource();
// อันนี้แปะไว้บนหัวสุด ก่อน page load เลยครับ
public void ShowReport()
{
string reportPath = System.Web.HttpContext.Current.Server.MapPath("test.rpt");
CRS.Report.FileName = reportPath;
this.SetParameter("FromDate", TextBox1.Text); // อันนี้ถ้ามี parameter ก็ยัดเข้าไป กี่ตัวก็ได้
this.SetParameter("ToDate", TextBox2.Text);
CrystalReportViewer1.ReportSource = CRS;
CrystalReportViewer1.DataBind();
}
public void SetParameter(string name, object value)
{
//Access the specified parameter from the parameters collection
CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition parameter = CRS.ReportDocument.DataDefinition.ParameterFields[name];
// Now get the current value for the parameter and clear them
CrystalDecisions.Shared.ParameterValues currentValues = parameter.CurrentValues;
currentValues.Clear();
// Create a value object for Crystal reports and assign the specified value.
CrystalDecisions.Shared.ParameterDiscreteValue newValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
newValue.Value = value;
// Now add the new value to the values collection and apply the
// collection to the report.
currentValues.Add(newValue);
parameter.ApplyCurrentValues(currentValues);
}
|
 |
 |
 |
 |
Date :
2010-03-06 20:30:59 |
By :
Aeo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|