我得到我的ReportViewer这我不知道如何纠正这种错误....我是gettings的错误是:“一个数据源实例尚未为数据源‘请求’提供。” 我试图寻找这一点,但无法找到任何东西,我可以看到这是错误的,可有人请点我在正确的方向? 这是我的reportvierer的样子:
<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>
这是我使用中的ReportViewer的代码:
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;
}