Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

report rdlc - data source error

$
0
0

I am trying to create a rdlc report but I am currently experiencing the following error --> A data source instance has not been supplied for the data source 'DataSet1'.

I have assigned my report with datasource from the client-end and as well server end, as shown below:

Report.aspx.cs

 protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/comp2.rdlc");
            dummyDataSet dsCustomers = GetData("select top 20 * from comp2");
            ReportDataSource datasource = new ReportDataSource("Comp2", dsCustomers.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(datasource);
        }

    }

    private dummyDataSet GetData(string query)
    {
        string conString = ConfigurationManager.ConnectionStrings["#######"].ConnectionString;
        SqlCommand cmd = new SqlCommand(query);
        using (SqlConnection con = new SqlConnection(conString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;

                sda.SelectCommand = cmd;
                using (dummyDataSet dsCustomers = new dummyDataSet())
                {
                    sda.Fill(dsCustomers, "DataTable2");
                    return dsCustomers;
                }
            }
        }

    }
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"><LocalReport ReportPath="comp2.rdlc"><DataSources><rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet2" /></DataSources></LocalReport></rsweb:ReportViewer><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="dummyDataSetTableAdapters.comp2TableAdapter"></asp:ObjectDataSource>

Am I missing something in the above codes?  Further hints would be very much appreciated.  Thank you


Viewing all articles
Browse latest Browse all 1418


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>