我的报告查看器出现错误,我不知道如何纠正这个错误......我得到的错误是:“没有为数据源'请求'提供数据源实例。” 我已尝试搜索此内容,但找不到任何我认为是错误的内容,有人可以指出我正确的方向吗?这就是我的记者的样子:
<rsweb:ReportViewer ID="rptViewer" runat="server" Height="654px"
Width="924px" Font-Names="Verdana" Font-Size="8pt"
InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report.rdlc">
</LocalReport>
这是我用于报告查看器的代码:
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
if (!Page.IsPostBack)
{
runRptViewer();
}
}
private DataTable getData()
{
DataSet dss = new DataSet();
string sql = "";
sql = "SELECT CC_Request.Company, CC_Request.Attention, CC_Request.Telephone, CC_Request.Email, CC_Items.Model, CC_Items.SerialNo, CC_ItemsRequested.Item, CC_ItemsRequested.Quantity, CC_ItemsRequested.Price, CC_ItemsRequested.ModelID, CC_Items.RequestID FROM CC_Request INNER JOIN CC_Items ON CC_Request.RequestID = CC_Items.RequestID INNER JOIN CC_ItemsRequested ON CC_Items.ModelID = CC_ItemsRequested.ModelID WHERE (CC_Request.Company = 'Alpha') AND (CC_ItemsRequested.ModelID = 20) AND (CC_Items.RequestID = 1)";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(dss);
DataTable dt = dss.Tables[0];
return dt;
}
private void runRptViewer()
{
this.rptViewer.Reset();
this.rptViewer.LocalReport.ReportPath = Server.MapPath("Reports\\Report.rdlc");
ReportDataSource rds = new ReportDataSource("dsNewDataSet_Table", getData());
this.rptViewer.LocalReport.DataSources.Clear();
this.rptViewer.LocalReport.DataSources.Add(rds);
this.rptViewer.DataBind();
this.rptViewer.LocalReport.Refresh();
}
任何帮助将不胜感激。
编辑 - - - - - - - - - - - -
这也不起作用:
private DataTable getData()
{
DataTable dtable = new DataTable();
dtable.TableName = "dtNewDataSet_Table";
string sql = "";
sql = "SELECT CC_Request.Company, CC_Request.Attention, CC_Request.Telephone, CC_Request.Email, CC_Items.Model, CC_Items.SerialNo, CC_ItemsRequested.Item, CC_ItemsRequested.Quantity, CC_ItemsRequested.Price, CC_ItemsRequested.ModelID, CC_Items.RequestID FROM CC_Request INNER JOIN CC_Items ON CC_Request.RequestID = CC_Items.RequestID INNER JOIN CC_ItemsRequested ON CC_Items.ModelID = CC_ItemsRequested.ModelID WHERE (CC_Request.Company = 'Alpha') AND (CC_ItemsRequested.ModelID = 20) AND (CC_Items.RequestID = 1)";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(dtable);
DataTable dt = dtable;
return dt;
}