ดูตัวอย่างนี้ครับ ใช้ Server.MapPath คืออ้างอิงจาก Root ของ Server ครับ
Code (C#)
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using CrystalDecisions.CrystalReports.Engine;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
}
protected void btnShowReport_Click(object sender, EventArgs e)
{
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("CrystalReport1.rpt"));
rpt.SetParameterValue("CustomerID", this.txtCustomerID.Text);
this.CrystalReportViewer1.ReportSource = rpt;
}
}