将DataSet绑定到Crystal报表 [英] Binding a DataSet to Crystal report

查看:62
本文介绍了将DataSet绑定到Crystal报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql select,用于计算"net"的总和。字段和"loads_today"的最大值领域。结果加载到DataSet中(使用vb代码)

MyAdsSelect ="选择ticket_date,customer,customer_description_1,job,
job_phase,job_description_1,m​​aterial,max(loads_today),sum(net)来自Salestkt,其中ticket_date =" &安培; """ &安培; MyDate& """ &安培; " group by ticket_date,
customer,customer_description_1,job,job_phase,job_description_1,
material"


除了选定的表字段外,DataSet现在还有两个附加列,一个用于"max loads_today"和一个"净值之和"。 DataSet绑定到DataGridView并显示。这很好用。以下是代码:

MyAdsAdapter.Fill(MyAdsDataset," MyAdsDataTable")

DataGridView1.DataSource = MyAdsDataset.Tables(" MyAdsDataTable" )


我也将相同的DataSet绑定到Crystal Report,它的工作正常,但以下情况除外:报告没有显示另外两个计算字段(它只显示从中选择的字段)已添加到Crystal报表中的表。)

MyCrystalReport.SetDataSource(MyAdsDataset.Tables(" MyAdsDataTable"))

MyCrystalReportViewer.ReportSource = MyCrystalReport



问题:我需要做些什么来显示"loads_today"的最大值?以及"净"的总和Crystal Report中的字段,因为这些字段不是来自表格吗?

谢谢。

I have a sql select that calculates the sum of a "net" field and  the max value of a "loads_today" field. The result is loaded into a  DataSet (using vb code)

MyAdsSelect = "Select ticket_date, customer, customer_description_1, job,
job_phase, job_description_1, material, max(loads_today), sum(net) from
Salestkt where ticket_date =" & "'" & MyDate & "'" & "group by ticket_date,
customer, customer_description_1, job, job_phase, job_description_1,
material"


The DataSet, in addition to selected table fields, now have two additional columns, one for "max loads_today" and one for "sum of net value". The DataSet is bound to a DataGridView and diplayed. This works fine. Here is the code:

MyAdsAdapter.Fill(MyAdsDataset, "MyAdsDataTable")
DataGridView1.DataSource = MyAdsDataset.Tables("MyAdsDataTable")


I am also binding the same DataSet to a Crystal Report and it works fine except for the following: The report does not show the additional two calculated fields (it only shows the fields selected from the table that have been added to the Crystal report).

MyCrystalReport.SetDataSource(MyAdsDataset.Tables("MyAdsDataTable"))
MyCrystalReportViewer.ReportSource = MyCrystalReport



Question: What do I need to do to show the max value of "loads_today" and the sum of the "net" field in Crystal Report since these tow field do not come from a table?

Thank you.

推荐答案

你应该从具有这两个额外列的数据集模式创建报告,以便您可以在设计时使用它们。
You should be creating the report off of the dataset schema that has these two extra columns so that you can use them at design time.


这篇关于将DataSet绑定到Crystal报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆