用ReportViewer动态加载rdlc文件时出了只读错误,请问是怎么回事?

妈妈baby坊 2011-03-15 11:58:26

string sqlcon = @"server=.\ALONG;database=RdlcTest;uid=sa;";
string sql = "select * from Table_Test";
System.Data.DataSet ds = new System.Data.DataSet();
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(sqlcon))
{
con.Open();
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
;
da.Fill(ds);

}
this.rpvConsumptionGraph.LocalReport.ReportPath = Server.MapPath("RdlcPieCharts.rdlc");//这个位置报的只读错误,请各位帮帮忙,看一下,谢谢

this.rpvConsumptionGraph.LocalReport.DataSources.Clear();

ReportDataSource rd = new ReportDataSource("DataSet1", ds.Tables[0]);
this.rpvConsumptionGraph.LocalReport.DataSources.Add(rd);
this.rpvConsumptionGraph.LocalReport.Refresh();


...全文
183 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
龙宜坡 2011-03-15
  • 打赏
  • 举报
回复
this.rptMain.Reset();
龙宜坡 2011-03-15
  • 打赏
  • 举报
回复
/// <summary>
/// 重新载入报表
/// </summary>
/// <param name="rdlcPath">rdlc文件绝对路径</param>
/// <param name="sqlSelect">SQL查询语句</param>
/// <param name="dataSourceName"></param>
/// <param name="paras"></param>
private void ReloadReport(string rdlcPath, string sqlSelect, string dataSourceName, params ReportParameter[] paras)
{
#region 数据库连接字符串
string _conn = String.Empty;
if (rdoServer.Checked)
{
_conn = RemoteHelper.ServerDbConnStr;
}
else
{
_conn = SqlHelper.strConn;
}
#endregion 数据库连接字符串

this.rptMain.Reset();
this.rptMain.LocalReport.ReportPath = rdlcPath;

if (paras != null && paras.Length > 0)
{
this.rptMain.LocalReport.SetParameters(paras);
}

this.rptMain.LocalReport.DataSources.Clear();
DataSet _ds = SqlHelper.ExecuteDataset(_conn, CommandType.Text, sqlSelect);
this.rptMain.LocalReport.DataSources.Add(new ReportDataSource(dataSourceName, _ds.Tables[0]));

this.rptMain.RefreshReport();
this.rptMain.SetDisplayMode(DisplayMode.PrintLayout);
this.rptMain.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
this.rptMain.ZoomPercent = 100;
}
-小蕾- 2011-03-15
  • 打赏
  • 举报
回复

private void frmPrint_Load(object sender, EventArgs e)
{
//显示报表内容
//int MemberId = Program.Num_id;
int MemberId = 1;
da = new MySqlDataAdapter("select a.MemberId as MemberId,MemberName,Score,Type from member as a left join memscore as b on a.memberid = b.memberid where a.memberid =" + MemberId + "", conn);
da.Fill(Mydata, "MyReportDataTable");

crystalReport11.Load(Application.StartupPath + "CrystalReport1.rpt");
crystalReport11.SetDataSource(Mydata);
crystalReportViewer1.ReportSource = crystalReport11;
crystalReportViewer1.ShowPrintButton = false;

}
-小蕾- 2011-03-15
  • 打赏
  • 举报
回复
this.rpvConsumptionGraph.LocalReport.ReportPath = Server.MapPath("CrystalReport1.rpt");//这个位置报的只读错误,请各位帮帮忙,看一下,谢谢
妈妈baby坊 2011-03-15
  • 打赏
  • 举报
回复
我的这个问题没有解决,刚才忘了说了reportviewer是放在MVC2框架里面的,求会的帮助

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧