Crystal Report刷新按钮不起作用 [英] Crystal Report Refresh Button Does Not Work
问题描述
美好的一天,
问题#1
我尝试使用下面的代码以编程方式填充我的crystalreport。
Good Day,
PROBLEM # 1
I tried populating my crystalreport programatically using code below.
Imports MySql.Data.MySqlClient
DIM obj_masterfile As New rpt_masterfile
public sub populate_data()
Dim da As New MySqlDataAdapter
da = New MySqlDataAdapter("select * from v_masterfile", cn)
Dim tbl_new As New DataTable
da.Fill(tbl_new)
obj_masterfile.SetDataSource(tbl_new)
frm_reports.Show()
frm_reports.CrystalReportViewer1.ReportSource = obj_masterfile
end sub
表名:v_masterfile
Table Name: v_masterfile
Emp_name Emp_age
Jay 21
John 23
Jayson 21
Jonny 24
这很好用,但是当我在crystalreportviewer中按下刷新按钮时,它在后端编辑数据时没有显示任何变化。
问题#2
由于某些原因,我不想通过ODBC(RDO)填充我的crystalreport所以我使用ADO.NET代替,基于我初始化的数据源(shft + alt + D)。
报告设计>数据库专家>项目数据> ADO.NET DataSet> v_masterfile
然后拖动 emp_ name
和 emp_age
on我的报告设计师
这里的问题是当我运行程序报告时没有显示任何记录。
注意:我尝试使用ODBC并且它可以工作,但我不需要使用ODBC,因为这将是一个使用动态连接字符串的客户端软件。
感谢您阅读。
This works great, however when i press the refresh button in crystalreportviewer it doesn't show any changes when i edit data at the backend.
PROBLEM # 2
For some reasons i don't want to populate my crystalreport via ODBC(RDO) so i used ADO.NET instead, based on the Data Source i initialized (shft + alt + D).
On Report Design > Database expert > Project Data> ADO.NET DataSets > v_masterfile
Then dragging emp_ name
and emp_age
on my report designer
The problem here is when i run the program reports does not shows any records.
NOTE: I tried using ODBC and it works, but i need not to use ODBC because this will be a client software that will use dynamic connection strings.
Thank you for reading.
推荐答案
问题1
数据不是刷新,因为报告仍然使用未刷新的旧数据源。您应该可以通过在报告刷新事件中再次选择来获得它。
Problem 1
The data is not refreshed because the report still use the old datasource which was not refreshed. You should be able to get it by doing select again at the report refresh event.
Private Sub CRViewer_ReportRefresh(ByVal source As Object, ByVal e As CrystalDecisions.Windows.Forms.ViewerEventArgs) Handles CRViewer.ReportRefresh
populate_data()
End Sub
Public Sub populate_data()
Dim da As New MySqlDataAdapter("select * from v_masterfile", cn)
Dim tbl_new As New DataTable
da.Fill(tbl_new)
obj_masterfile.SetDataSource(tbl_new)
End Sub
我自己没有尝试代码,所以相应调整。
问题2
好了,因为你以编程方式获取数据然后如果你想使用不同的连接那么你应该在连接时这样做初始化而不是报告本身(在查询数据库以获取数据之前)。
报告得到了它需要的数据源,它会像你设计的一样工作。
I didn't try the code myself so adjust accordingly.
Problem 2
Well since you're getting the data programmatically then if you want to use different connection then you should be doing it at the connection initialization instead of at the report itself (before querying the database to get data).
What matter is the report got the datasource it requires and it would work like you have designed it.
这篇关于Crystal Report刷新按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!