A data source instance has not been supplied for the data source 'Request'
Solution 1
I was also facing this problem that's why I came here.
I figure out the problem and I am posting that here to help some one who get this type of issue.
- My data source of RDLC was "dsClientPayList"
I was adding the data source in my code behind like:
ReportViewer1.LocalReport.DataSources.Clear(); ReportDataSource rd = new ReportDataSource("dsData1", DAL.MyDBModel.snData().Tables[0]); ReportViewer1.LocalReport.DataSources.Add(rd);
and it was throwing same error.
Solution:
In my code behind I changed the parameter of ReportDataSource from "dsData1" to "dsClientPayList" (same as in RDLC).
ReportDataSource rd = new ReportDataSource("dsClientPayList", DAL.MyDBModel.snData().Tables[0]);
And it works
Conclusion: The DataSource name must be same in both RDLC and ReportViewer.
Thanks Happy Coding :)
Solution 2
You have to set all of the datasources that using in the report.
In this case if there is only one datasource it should be like this
ReportDataSource rds = new ReportDataSource("Request", getData());
Comments
-
Kerieks almost 2 years
I'm getting an error on my reportviewer which I am not sure how to correct this.... The error that I am gettings is : " A data source instance has not been supplied for the data source 'Request'." I have tried searching for this, but can't find anything that I can see that is wrong, can somebody please point me in the right direction? This is how my reportvierer looks like:
<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>
This is the code I use for the 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(); }
Any help will be greatly appreciated.
EDIT-----------------------
this does not work either:
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; }
-
Kerieks about 11 yearsit there is multiple (I've got 3) do I must add 3 ReportDataSources and then add them 3 times to the Local Report Data Sources? I have done this, but it casuses the reportviewer to go not display (like being totally invisible)?
-
wy__ about 11 yearsyes, add all of those datasources being used in your report, ensure the datasource name is correct.
-
Baqer Naqvi over 9 yearsWorked for me too! :)