Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Error: Subreport could not be shown" when trying to view the report u

Status
Not open for further replies.

ArpitaGarg

Programmer
Jan 24, 2007
1
GB
Hi,

This is an urgent query. Appriciate early response.
I am new to ASP.NET. I am getting the error "Error: Subreport could not be shown" when trying to view the report using ReportViewer.

I have been trying to figure out this for the past 2 days but in vain. I ahve tried all the possible solutions from the net but no success.

The code sample :-
ReportViewer.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ReportViewer.aspx.cs" Inherits="ReportViewer" Title="Client Service Database - Futures" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
&nbsp;<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="500px" Width="800px">
<LocalReport ReportPath="Report.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet2_CLIENTINFO" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData" TypeName="DataSet2TableAdapters.CLIENTINFOTableAdapter"></asp:ObjectDataSource>

</asp:Content>

ReportViewer.aspx.cs
using System;
using System.IO;
using System.Data;
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 partial class ReportViewer : System.Web.UI.Page
{
private DataTable ClientContactData = null;
private DataTable ClientAccountData = null;

public DataTable LoadClientData()
{
DataSet2 dset = new DataSet2();
return dset.Tables["CLIENTINFO"];
}

public DataTable LoadClientContact()
{
DataSet2 dset = new DataSet2();
return dset.Tables["CLIENTCONTACT"];
}

public DataTable LoadClientAccount()
{
DataSet2 dataset = new DataSet2();
return dataset.Tables["CLIENTACCOUNT"];
}

public void DemoSubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
if (ClientContactData == null)
{
ClientContactData = LoadClientContact();
e.DataSources.Add(new ReportDataSource("DataSet2_CLIENTCONTACT", ClientContactData));
}

if (ClientAccountData == null)
{
ClientAccountData = LoadClientAccount();
e.DataSources.Add(new ReportDataSource("DataSet2_CLIENTACCOUNT", ClientAccountData));
}
}

protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(DemoSubreportProcessingEventHandler);
if (!IsPostBack)
{
// Set RDL File
ReportViewer1.LocalReport.ReportPath = @"F:\Visual Studio 2005\WebSites\CSD\Report.rdlc";
// Supply DataTable corresponding to each report dataset
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2_CLIENTINFO", LoadClientData()));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2_CLIENTCONTACT", LoadClientContact()));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2_CLIENTACCOUNT", LoadClientAccount()));
}
}
}


DataSet2.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="DataSet2" targetNamespace=" xmlns:mstns=" xmlns=" xmlns:xs=" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="ConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="ConnectionString (Web.config)" PropertyReference="AppConfig.System.Configuration.ConfigurationManager.0.ConnectionStrings.ConnectionString.ConnectionString" Provider="System.Data.OracleClient">
</Connection>
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="CLIENTINFOTableAdapter" GeneratorDataComponentClassName="CLIENTINFOTableAdapter" Name="CLIENTINFO" UserDataComponentName="CLIENTINFOTableAdapter">
<MainSource>
<DbSource ConnectionRef="ConnectionString (Web.config)" DbObjectType="Unknown" GenerateMethods="Get" GenerateShortCommands="False" GeneratorGetMethodName="GetData" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False" UserGetMethodName="GetData" UserSourceName="GetData">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT CLIENTINFO.CLIENTID, CLIENTINFO.ADDRESS, CLIENTINFO.POSTCODE, CLIENTINFO.COUNTRY
FROM CLIENTINFO, CLIENT
WHERE CLIENTINFO.CLIENTID = CLIENT.CLIENTID
ORDER BY CLIENTINFO.CLIENTID</CommandText>
<Parameters>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="CLIENTID" DataSetColumn="CLIENTID" />
<Mapping SourceColumn="ADDRESS" DataSetColumn="ADDRESS" />
<Mapping SourceColumn="POSTCODE" DataSetColumn="POSTCODE" />
<Mapping SourceColumn="COUNTRY" DataSetColumn="COUNTRY" />
</Mappings>
<Sources>
</Sources>
</TableAdapter>
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="CLIENTCONTACTTableAdapter" GeneratorDataComponentClassName="CLIENTCONTACTTableAdapter" Name="CLIENTCONTACT" UserDataComponentName="CLIENTCONTACTTableAdapter">
<MainSource>
<DbSource ConnectionRef="ConnectionString (Web.config)" DbObjectName="CSD_OWNER.CLIENTCONTACT" DbObjectType="Table" GenerateMethods="Get" GenerateShortCommands="False" GeneratorGetMethodName="GetData" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False" UserGetMethodName="GetData" UserSourceName="GetData">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT CLIENTID, CONTACTNAME
FROM CLIENTCONTACT CC
WHERE (CLIENTID = :ClientId)</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName="ClientId" ColumnName="CLIENTID" DataSourceName="CSD_OWNER.CLIENTCONTACT" DataTypeServer="NUMBER(22)" DbType="Decimal" Direction="Input" ParameterName="ClientId" Precision="6" ProviderType="Number" Scale="0" Size="22" SourceColumn="CLIENTID" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="CLIENTID" DataSetColumn="CLIENTID" />
<Mapping SourceColumn="CONTACTNAME" DataSetColumn="CONTACTNAME" />
</Mappings>
<Sources>
</Sources>
</TableAdapter>
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="CLIENTACCOUNTTableAdapter" GeneratorDataComponentClassName="CLIENTACCOUNTTableAdapter" Name="CLIENTACCOUNT" UserDataComponentName="CLIENTACCOUNTTableAdapter">
<MainSource>
<DbSource ConnectionRef="ConnectionString (Web.config)" DbObjectType="Unknown" GenerateMethods="Get" GenerateShortCommands="False" GeneratorGetMethodName="GetData" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="False" UserGetMethodName="GetData" UserSourceName="GetData">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT CLIENTID, ACCOUNTNUMBER
FROM CLIENTACCOUNT
WHERE CA.CLIENTID = :ClientId
</CommandText>
<Parameters>
<Parameter AllowDbNull="True" AutogeneratedName="ClientId" ColumnName="CLIENTID" DataSourceName="CSD_OWNER.CLIENTACCOUNT" DataTypeServer="NUMBER(22)" DbType="Decimal" Direction="Input" ParameterName="ClientId" Precision="6" ProviderType="Number" Scale="0" Size="22" SourceColumn="CLIENTID" SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="ACCOUNTNUMBER" DataSetColumn="ACCOUNTNUMBER" />
</Mappings>
<Sources>
</Sources>
</TableAdapter>
</Tables>
<Sources>
</Sources>
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="DataSet2" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="DataSet2" msprop:Generator_DataSetName="DataSet2">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="CLIENTINFO" msprop:Generator_UserTableName="CLIENTINFO" msprop:Generator_RowDeletedName="CLIENTINFORowDeleted" msprop:Generator_RowChangedName="CLIENTINFORowChanged" msprop:Generator_RowClassName="CLIENTINFORow" msprop:Generator_RowChangingName="CLIENTINFORowChanging" msprop:Generator_RowEvArgName="CLIENTINFORowChangeEvent" msprop:Generator_RowEvHandlerName="CLIENTINFORowChangeEventHandler" msprop:Generator_TableClassName="CLIENTINFODataTable" msprop:Generator_TableVarName="tableCLIENTINFO" msprop:Generator_RowDeletingName="CLIENTINFORowDeleting" msprop:Generator_TablePropName="CLIENTINFO">
<xs:complexType>
<xs:sequence>
<xs:element name="CLIENTID" msprop:Generator_UserColumnName="CLIENTID" msprop:Generator_ColumnPropNameInRow="CLIENTID" msprop:Generator_ColumnVarNameInTable="columnCLIENTID" msprop:Generator_ColumnPropNameInTable="CLIENTIDColumn" type="xs:decimal" minOccurs="0" />
<xs:element name="ADDRESS" msprop:Generator_UserColumnName="ADDRESS" msprop:Generator_ColumnPropNameInRow="ADDRESS" msprop:Generator_ColumnVarNameInTable="columnADDRESS" msprop:Generator_ColumnPropNameInTable="ADDRESSColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="300" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="POSTCODE" msprop:Generator_UserColumnName="POSTCODE" msprop:Generator_ColumnPropNameInRow="POSTCODE" msprop:Generator_ColumnVarNameInTable="columnPOSTCODE" msprop:Generator_ColumnPropNameInTable="POSTCODEColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="COUNTRY" msprop:Generator_UserColumnName="COUNTRY" msprop:Generator_ColumnPropNameInRow="COUNTRY" msprop:Generator_ColumnVarNameInTable="columnCOUNTRY" msprop:Generator_ColumnPropNameInTable="COUNTRYColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLIENTCONTACT" msprop:Generator_UserTableName="CLIENTCONTACT" msprop:Generator_RowDeletedName="CLIENTCONTACTRowDeleted" msprop:Generator_RowChangedName="CLIENTCONTACTRowChanged" msprop:Generator_RowClassName="CLIENTCONTACTRow" msprop:Generator_RowChangingName="CLIENTCONTACTRowChanging" msprop:Generator_RowEvArgName="CLIENTCONTACTRowChangeEvent" msprop:Generator_RowEvHandlerName="CLIENTCONTACTRowChangeEventHandler" msprop:Generator_TableClassName="CLIENTCONTACTDataTable" msprop:Generator_TableVarName="tableCLIENTCONTACT" msprop:Generator_RowDeletingName="CLIENTCONTACTRowDeleting" msprop:Generator_TablePropName="CLIENTCONTACT">
<xs:complexType>
<xs:sequence>
<xs:element name="CLIENTID" msprop:Generator_UserColumnName="CLIENTID" msprop:Generator_ColumnVarNameInTable="columnCLIENTID" msprop:Generator_ColumnPropNameInRow="CLIENTID" msprop:Generator_ColumnPropNameInTable="CLIENTIDColumn" type="xs:decimal" minOccurs="0" />
<xs:element name="CONTACTNAME" msprop:Generator_UserColumnName="CONTACTNAME" msprop:Generator_ColumnVarNameInTable="columnCONTACTNAME" msprop:Generator_ColumnPropNameInRow="CONTACTNAME" msprop:Generator_ColumnPropNameInTable="CONTACTNAMEColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="30" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CLIENTACCOUNT" msprop:Generator_UserTableName="CLIENTACCOUNT" msprop:Generator_RowDeletedName="CLIENTACCOUNTRowDeleted" msprop:Generator_RowChangedName="CLIENTACCOUNTRowChanged" msprop:Generator_RowClassName="CLIENTACCOUNTRow" msprop:Generator_RowChangingName="CLIENTACCOUNTRowChanging" msprop:Generator_RowEvArgName="CLIENTACCOUNTRowChangeEvent" msprop:Generator_RowEvHandlerName="CLIENTACCOUNTRowChangeEventHandler" msprop:Generator_TableClassName="CLIENTACCOUNTDataTable" msprop:Generator_TableVarName="tableCLIENTACCOUNT" msprop:Generator_RowDeletingName="CLIENTACCOUNTRowDeleting" msprop:Generator_TablePropName="CLIENTACCOUNT">
<xs:complexType>
<xs:sequence>
<xs:element name="ACCOUNTNUMBER" msprop:Generator_UserColumnName="ACCOUNTNUMBER" msprop:Generator_ColumnPropNameInRow="ACCOUNTNUMBER" msprop:Generator_ColumnVarNameInTable="columnACCOUNTNUMBER" msprop:Generator_ColumnPropNameInTable="ACCOUNTNUMBERColumn" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="30" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

The main report does not take any parameters.
Sub-Report takes a parameter clientid from the mainreport

Thanks for all the help.

Arpita
 
Does it work when you deploy to the server ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top