Reputation: 5705
In my ASP.Net Web pages project I have created a new Web page and I dragged a script manager control onto it, then I created a new rdlc report using the wizard and configured the dataset (to show 3 fields of Products table: ProductName, quatityPerUnit, Price) which begun to retrieve data.
At the following step, I inserted a new Reportviewer and bound it to the previously created report, then again I verified that the data is retrieved by opening the dataset1.xsd file and clicking on preview data.
and this is my web page body code:
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Reports\MyRdlcReport.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="dsProducts" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="WebApplication1.dsProductsTableAdapters.ProductsTableAdapter">
</asp:ObjectDataSource>
</div>
</form>
</body>
But When I run the project, I get the next error: A data source instance has not been supplied for the data source ‘dataSource1’, I have tried to find a similar case on the net but succeeded to find nothing, any help please ?
Upvotes: 2
Views: 61693
Reputation: 43
// ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(Student);
In pageload make sure the above clear function for ReportViewer
is made as comment or deleted to avoid the Data source
instance has not be supplied error.
Upvotes: 0
Reputation: 1
Visual Studio 13 offers an elegant solution to handle parameters in a sql server stored procedure:
ReportViewer Steps To Create A Web Report using the Web version of the reportviewer
Create Webform using Website/Add New Item
Drag ReportViewer on Webpage
Select New data source or the report will give an error:
A data source instance has not been supplied for the data source’
A new screen will appear showing various data sources. Normally choose SQL data
Choose specify custom SLQ statement then hit NEXT
Choose stored procedure or choose SLQ statement and use the query builder. Choosing stored procedure will allow the user to pick controls for the parameters of the stored procedure. The wizard will then properly configure the web code thus eliminating any need for entering vb code such as below:
Protected Sub ReportViewer1_Load(sender As Object, e As EventArgs) Handles ReportViewer1.Load Dim Parm As New ReportParameter("BillingReportParm1", Profile.TherapistNo) ReportViewer1.LocalReport.SetParameters(Parm) ReportViewer1.LocalReport.Refresh() End Sub
<asp:Content ID="Content2" ContentPlaceHolderID="cpMC" Runat="Server">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="383px" Width="721px">
<LocalReport ReportPath="Reports\BillingPendingRpt.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="SqlDataPendRpt" Name="BillingPendingRptDataSet" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:SqlDataSource ID="SqlDataPendRpt" runat="server" ConnectionString="<%$ ConnectionStrings:MMBDataConnectionString %>" SelectCommand="sp_WorkHour_Rpt" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ProfileParameter Name="Therapist" PropertyName="TherapistNo" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Upvotes: -1
Reputation: 5705
Finally I found the cause, it was a non corresponding Tablix data set name property. I had to rename it from dataSet1 to dsProducts.
Upvotes: 4
Reputation: 29000
You must realize the last step who is defining of datasource
link : http://ruchitech.blogspot.fr/2012/07/how-to-create-rdlc-report-in-c.html
Note : see Choose Data Source
Upvotes: 5