Sami-L
Sami-L

Reputation: 5705

rdlc report - ‘A data source instance has not been supplied for the data source’ error

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

Answers (4)

garlic bread
garlic bread

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

Dick
Dick

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

  1. Create Webform using Website/Add New Item

  2. Drag ReportViewer on Webpage

  3. Choose create new report (rdlc)
  4. Select datasource for the report (be sure to rename before saving)
  5. Use report generator to place fields on the report.
  6. Save the report then rename default of report1.rdlc to the name desired
  7. Move report and webpage to desired directory
  8. Go to webpage reportviewer tasks and select the report.
  9. Then choose data source (Parameters for the report can be added in the datasource)

Select New data source or the report will give an error:

A data source instance has not been supplied for the data source’

  1. A new screen will appear showing various data sources. Normally choose SQL data

  2. Choose specify custom SLQ statement then hit NEXT

  3. 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
  1. An Example of the finished HTML code is shown below:

<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

Sami-L
Sami-L

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

Aghilas Yakoub
Aghilas Yakoub

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

enter image description here

Upvotes: 5

Related Questions