Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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:
C#
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using Microsoft.Reporting.WebForms;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
       private DataTable GetData(DateTime fromDate, DateTime toDate)
    {
        DataTable dt = new DataTable();
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Data"].ConnectionString);
        {
            SqlCommand cmd = new SqlCommand("GetOrderByDates", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@From", SqlDbType.DateTime).Value = fromDate;
            cmd.Parameters.Add("@To", SqlDbType.DateTime).Value = toDate;

            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(dt);
        }
        return (dt);
    }

    protected void btnShow_Click(object sender, EventArgs e)
    {
       rptViewer.Reset();

        DataTable dt = GetData(DateTime.Parse(txtFrom.Text), DateTime.Parse(txtTo.Text));
        ReportDataSource rds = new ReportDataSource("Data", dt);
        rptViewer.LocalReport.ReportPath = "Data.rdlc";
        ReportParameter[] rptParams = new ReportParameter[] {
new ReportParameter("fromDate", txtFrom.Text),
new ReportParameter("toDate", txtTo.Text)
};
        rptViewer.LocalReport.SetParameters(rptParams);
        rptViewer.LocalReport.Refresh();
    }
}

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 ?
Posted
Comments
ArunRajendra 25-May-15 23:45pm    
In which line are you getting this error? Just one guess you are getting the data into ReportDataSource (rds). But where is this associated with report. somthing like rptViewer.LocalReport.DataSource = rds;
abdo.kouta 26-May-15 3:32am    
I gettig this error once i start my website to test and i have made the data source for the report and i selected the report path from the small areo next to the report in page design and this line is the >>>>ReportDataSource rds = new ReportDataSource("Data", dt);<<<< Data is the Dataset... so i think everything is fine but i'm keeping get this error message ??

1 solution

C#
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionstrings>
    <add name="Data" connectionstring="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Data.mdf;Integrated Security=True" providername="System.Data.SqlClient" />
  </connectionstrings>
  <system.web>
    <httphandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91">
        validate="false" />
    </add></httphandlers>
    <compilation debug="true" targetframework="4.5">
      <assemblies>
        <add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
        <add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
        <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
      <buildproviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      </buildproviders>
    </compilation>
    <httpruntime targetframework="4.5" />
  </system.web>
  <system.webserver>
    <validation validateintegratedmodeconfiguration="false" />
    <handlers>
      <add name="ReportViewerWebControlHandler" precondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </handlers>
  </system.webserver>
</configuration>

this is my config code
 
Share this answer
 
v2
Comments
gggustafson 26-May-15 11:58am    
You understand that by placing your code in a Solution, no one will see your question again (as it has been "solved"). You should place this in your original question and delete this solution. I object to a large amount of code being submitted. You need to pare down your submission to only that which is necessary.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900