我有一个包含2个报告的asp.net页面。一份报告工作正常。当我运行第二个时它向我显示此错误。我尝试过在互联网上找到的许多解决方案。有人请帮我这个
我的CS代码是
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/mainaccount.rdlc");
mainaccount dsmainaccount = GetData("select TB_MAIN_ACNT_NAME ,TB_MAIN_ACNT_CODE,TB_OP_BAL ,TB_CR_DT ,TB_TXN_DEBIT ,TB_TXN_CREDIT ,TB_CL_BAL_DR ,TB_CL_BAL_CR FROM FT_TRIALBAL_MPG WHERE TB_COMP_CODE='MCS' and TB_SYS_ID=233");
ReportDataSource datasourcemain = new ReportDataSource("mainaccount", dsmainaccount.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasourcemain);
}
}
private mainaccount GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["OrionConnectionString"].ConnectionString;
OracleCommand cmd = new OracleCommand(query);
using (OracleConnection con = new OracleConnection(conString))
{
using (OracleDataAdapter sda = new OracleDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (mainaccount dsmainaccount = new mainaccount())
{
sda.Fill(dsmainaccount, "DataTable2");
return dsmainaccount;
}
}
}
}
我的aspx页面代码是
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font- Names="Verdana" Font-Size="8pt"
WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="mainaccount.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="dataset2" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="Select" TypeName="trialbalance.mainaccount+DataTable2DataTable"> </asp:ObjectDataSource>
<br />
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
两个报告都使用相同的DataSet?
ReportDataSource datasourcemain = new ReportDataSource(“mainaccount”,dsmainaccount.Tables [1]);
这是为了帮助您在报告中显示的确切错误?
答案 1 :(得分:0)
然后您必须填写两个dataSet并将它们传输到本地报告,如下图所示: