SOS求助,水晶报表加载正常,但按下一页的时候就提示要登录信息

desnoc 2020-08-01 04:49:43


#region 变量
private string stype;
private string swhere;
private ReportDocument rpt = new ReportDocument();
cashier.business.bi.ConsumerBI cbi = cashier.business.ABusinessFactory.BusinessFactory.CreateConsumerBI();
#endregion

//设置体检报告数据源
private void SetTJBGDataSource(string swhere)
{
try
{

//主报表数据
DataView dv = cbi.GetTJDataSource(swhere);
DataView dv1= cbi.GetTJDataSource(swhere);
DataView dv2 = cbi.GetTJDataSource(swhere);


string tjbh = string.Empty;

if (dv != null && dv.Count > 0)
{
tjbh = dv[0]["tjbh"].ToString();
}

DataView dvjg = cbi.GetTJJGDataSource("tjbh='" + tjbh + "'");


TableLogOnInfo logOnInfo = new TableLogOnInfo();
//这里必须事先申明一个ReportDocument对象 Report,同时加载数据报表

//建立安全信息
//受密码保护的 Microsoft Access 和 Paradox 等 PC 数据库也使用该方法,但 LogOnInfo.ServerName //和 LogOnInfo.DatabaseName 要保留为空
logOnInfo.ConnectionInfo.ServerName = @"URSN3B65HP9TWOC\SQLEXPRESS";
logOnInfo.ConnectionInfo.DatabaseName = "LIS";
logOnInfo.ConnectionInfo.UserID = "sa";
logOnInfo.ConnectionInfo.Password = "sc1234";

//logOnInfo.ConnectionInfo.ServerName = @"192.168.100.3";
//logOnInfo.ConnectionInfo.DatabaseName = "LIS";
//logOnInfo.ConnectionInfo.UserID = "sa";
//logOnInfo.ConnectionInfo.Password = "123.com";

string path = Server.MapPath(@"\CrystalReport3.rpt");

rpt.Load(path);

for (int i = 0; i < rpt.Database.Tables.Count; i++)
{
rpt.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
}


//rpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);

//obj.SetDataSource(this.ds.Tables["tablename"]
rpt.SetDataSource(dv.Table);

rpt.OpenSubreport("GRWord").SetDataSource(dv1.Table);
rpt.OpenSubreport("JYZ").SetDataSource(dv2.Table);
rpt.OpenSubreport("JYJGRPT").SetDataSource(dvjg.Table);


//建立.rpt文件与CryStalReportviewer文件之间的连接
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.Visible = true;

rpt.Refresh();

}
catch (Exception ex)
{
lblmsg.Text = ex.Message;
}
}
protected override void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
if (!IsPostBack)
{
//swhere = Session["stwhere"].ToString();
//stype = Session["stype"].ToString();

SetTJBGDataSource(" where [XM]='李俊'");

}
}
...全文
9477 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
EdsionWang 2020-08-13
  • 打赏
  • 举报
回复
https://my.oschina.net/u/4346073/blog/3673133 b:代码没有放到Page_Load或Page_init里,或者是放到了,但是控制了 postback。 因为http是无状态的,如果控制了postback,水晶报表就丢失了前面的设置,会导致出现此情况的

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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