【发布时间】:2012-01-08 08:55:21
【问题描述】:
我有一份报告需要从我的应用程序 DAL 的两个逻辑区域 Vendors.xsd 和 Customers.xsd 中获取数据。我可以使用 Database Expert 将 DataSets 和它们的 DataTables 都放入报告中,但是我得到了这个错误:
此报告中使用了多个数据源或存储过程。 请确保没有添加 SQL 表达式并且没有服务器端 group_by 执行。
关于报表构建/设计的一切似乎都运行良好。当我实际运行报告时,它要求我登录到两个 DataSet 之一(似乎是我添加的第二个)并且没有获取数据。
我测试并确认如果我将所有表放在一个 xsd 中开始,我没有这个问题。
编辑
这是我用来加载报告的代码:
Protected Sub CrystalReportViewer1_Init(sender As Object, e As EventArgs) Handles CrystalReportViewer1.Init
'Get Customer ID param
Dim CustomerID As Integer
If Not Integer.TryParse(Request.QueryString("CustomerID"), CustomerID) Then
CancelReportOnError("You must provide a customer ID!")
End If
'Get address type ID param
Dim AddressTypeID As Integer
If Not Integer.TryParse(Request.QueryString("AddressTypeID"), AddressTypeID) Then
CancelReportOnError("You must provide an address type!")
End If
'Gather report data --
'Address
Dim customersControl As New BLL.Customers()
Dim AddressData As DAL.Customers.AddressesDataTable = customersControl.GetAddressByCustomerID(CustomerID, AddressTypeID)
AddressData.TableName = "Addresses"
'Customer
Dim CustomerData As DAL.Customers.CustomersDataTable = customersControl.GetCustomerByID(CustomerID)
CustomerData.TableName = "Customers"
'Confirm customer exists
If CustomerData.Count = 0 Or AddressData.Count = 0 Then
CancelReportOnError(String.Format("Could not find Customer with ID {0}", CustomerID))
End If
'Vendor
Dim vendorsControl As New BLL.Vendors()
Dim VendorData As DAL.Vendors.VendorsDataTable = vendorsControl.GetVendordByCustomerID(CustomerID)
VendorData.TableName = "Vendors"
'Confirm vendor exists
If VendorData.Count = 0 Then
CancelReportOnError(String.Format("Could not find a Vendor associated with Customer ID {0}", CustomerID))
End If
'Build data source
Dim ReportData As New DataSet()
ReportData.Tables.Add(VendorData)
ReportData.Tables.Add(CustomerData)
ReportData.Tables.Add(AddressData)
ReportData.Relations.Add(CustomerData.CustomerIDColumn, AddressData.CustomerIDColumn)
ReportData.Relations.Add(VendorData.VendorIDColumn, CustomerData.VendorIDColumn)
'Load the report
Dim Report As New ReportDocument()
Report.Load(Server.MapPath("~/Members/Customers/MailingEnvelope.rpt"))
Report.SetDataSource(ReportData)
'Set the report to our viewer
CrystalReportViewer1.ReportSource = Report
CrystalReportViewer1.DataBind()
End Sub
【问题讨论】:
标签: asp.net visual-studio crystal-reports dataset