asp.net - Crystal Reports 的问题无法反映 SQL DB 的更改
问题描述
我对在 Visual Studio 2017 上使用 Crystal Reports 创建报表有点陌生。我使用设置向导在 VS2017 上创建了一个名为 PersonnelListingReport.rpt 的报表。通过向导,我选择了报告将基于的表。此外,我添加了一个过滤器参数,该参数将仅显示处于活动状态的员工,即(活动 = 1,非活动 = 0)。所以现在在我的主报告预览窗口中,我可以看到所有状态 = 1 的员工。我的问题是,当我在 GridView 上添加或删除项目时,更改不会反映在我的报告中。这是我的 Page_Load 中的内容:
Public Class PersonnelListingReportViewer
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim crystalReport As New ReportDocument()
crystalReport.Load(Server.MapPath("PersonnelListingReport.rpt"))
CrystalReportViewer1.ReportSource = crystalReport
End Sub
这是我在我的 aspx 下的 ReportViewer 的内容:
body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="1202px" ReportSourceID="CrystalReportSource1" ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="PersonnelListingReport.rpt">
</Report>
</CR:CrystalReportSource>
</div>
</form>
我的代码中是否缺少某些内容?我已经尝试根据论坛帖子使用 Refresh() 和 Load() 有类似问题但无济于事。我还阅读了有关创建 Page_Unload 的论坛帖子,然后让报告调用 Close() 然后 Dispose() 但也无济于事。我试过选中复选框以在加载报告时丢弃保存的数据,但仍然没有。我知道我遗漏了一些东西,但不太确定,因为这是我第一次在 Visual Studio 2017 上使用 Crystal Reports。谢谢大家!
解决方案
谢谢大家的建议。我能够通过将其添加到我的 Page_Load 来解决该问题:
Dim cryRpt As New ReportDocument
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
cryRpt.Load(Server.MapPath("PersonnelListingReport.rpt"))
With crConnectionInfo
.ServerName = "0.0.0.0"
.DatabaseName = "TestDB"
.UserID = "user"
.Password = "pw"
End With
CrTables = cryRpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.RefreshReport()
推荐阅读
- stanford-nlp - ELMo、BERT 和 GloVe 之间的比较
- firebase-authentication - Firebase 身份验证提供程序默默地从密码更改为 google.com
- azure - 工作人员服务中的事件登录未发布到 Azure Application Insight
- javascript - 无法使用 useState 挂钩设置值?为什么会发生这种情况?
- maven - Maven - pom文件 - 未创建工件
- mysql - 在node express中根据mysql数据库中的角色值实现用户角色
- vim - 增加或减少数字同时
和 Cx> 绑定在 vim 中未映射 - javascript - 如何在 Spark AR 的脚本编辑器中将纹理应用到材质
- ruby-on-rails - 如何从错误中读取 Rails 验证?
- python - 在函数定义中为返回类型添加换行符