ReportViewer

Discussion in 'ASP.NET 2.0' started by NewMind, Oct 3, 2006.

  1. I get the following error any time I try to bring up a reportViewer control.

    Server Error in '/' Application.
    --------------------------------------------------------------------------------
    The specified module could not be found. (Exception from HRESULT: 0x8007007E)
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    huh.. need more information.


    Can you send us some code snippet?


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. <%@ Control Language="c#" AutoEventWireup="false" Codebehind="MainTestCenter.ascx.cs" Inherits="NewmindApps.UI.modules.MainTestCenter" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>

    <rsweb:ReportViewer ID="ReportViewer1"
    runat="server"
    Font-Names="Verdana"
    Font-Size="8pt"
    Height="100%"
    BackColor="#F3F3FE"
    Width="100%">
    </rsweb:ReportViewer>


    <asp:Button ID="testButton" Runat="server" Text="Test" OnClick="TestButton_Click"></asp:Button>

    </body>
    </HTML>



    ----------------------------------------------------------------------------------------------------------
    Code behind


    ----------------------------------------------------------------------------------------------------------

    namespace NewmindApps.UI.modules
    {
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Microsoft.Reporting.WebForms;


    public class MainTestCenter : System.Web.UI.UserControl
    {
    protected System.Web.UI.WebControls.Button testButton;

    protected ReportViewer ReportViewer1;
    private const string connectionKeyString = "Main.ConnectionString";

    private void Page_Load(object sender, System.EventArgs e)
    {
    LoadReport();
    }

    private void LoadReport()
    {

    // Get db Connection string
    AppSettingsReader configReader = new AppSettingsReader();
    string connString = configReader.GetValue("Main.ConnectionString", typeof(string)).ToString();

    // Create Command
    SqlCommand command = new SqlCommand("PROC_xxx", new SqlConnection(connString));
    command.CommandType = CommandType.StoredProcedure;
    command.Parameters.Add("@ID", SqlDbType.Int).Value = 45;

    //Fill DataSet
    System.Data.DataSet dsReport = new System.Data.DataSet();
    SqlDataAdapter dp = new SqlDataAdapter(command);
    dp.Fill(dsReport);

    // Set/link DataSet to DataSource
    ReportDataSource datasource = new ReportDataSource(
    "EEGResults_PROC_xxx", dsReport.Tables[0]);

    // Set Embedded Resource Link
    ReportViewer1.LocalReport.ReportEmbeddedResource =
    "xxx.REPORTS.xxx.xxx.rdlc";

    // Set report Path
    ReportViewer1.LocalReport.ReportPath = Server.MapPath(
    @"~/Reports/xxx/xxx.rdlc");

    // Reload Report DataSources
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(datasource);
    if (dsReport.Tables[0].Rows.Count == 0)
    {
    //Display no data message";
    }

    // Refresh/render report
    ReportViewer1.LocalReport.Refresh();
    }
     
  4. Do you have the dll for Microsoft.ReportViewer.WebForms in your ~/bin directory?


    I don't know much about this specific library, so I don't really know what is involved in installtion of it.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     

Share This Page