[英]Cannot use Stored Procedure in SQL Server 2012 within VS2013 Report Designer, always returns blank?
I'm attempting to create a parameterized report within a C# application. 我正在尝试在C#应用程序中创建参数化报表。 When I go to the Data Source Designer, I can select preview, and see the appropriate data just fine.
当我进入数据源设计器时,我可以选择预览,然后适当地查看适当的数据。 However, when I attempt to create a report with the stored procedure, the report ends up being blank, as if no rows are returned
但是,当我尝试使用存储过程创建报告时,该报告最终为空白,就像没有返回任何行一样
If I create a brand new report, without the parameters, it still returns blank. 如果我创建一个没有参数的全新报告,它仍然返回空白。 However, my views and tables pull just fine.
但是,我的视图和表格都很好。
Any ideas? 有任何想法吗?
EDIT 编辑
Code Attempt 1 代码尝试1
ALTER PROCEDURE [dbo].[getReportData]
@minimumDate DATE = '1900-01-01',
@maximumDate DATE = '2100-12-31',
@PO INT = null,
@glCode INT = null,
@merchant INT = null,
@employee INT = null
AS
BEGIN
SET NOCOUNT ON;
SELECT dbo.transactions.date_purchased,
dbo.transactions.description,
dbo.transactions.purchase_order_number,
dbo.transaction_codes.transaction_code,
dbo.merchants.merchant,
dbo.transactions.amount,
dbo.employees.first_name + ' ' + dbo.employees.last_name AS employee
FROM dbo.transactions
INNER JOIN dbo.transaction_codes ON dbo.transactions.accounting_code = dbo.transaction_codes.id
INNER JOIN dbo.merchants ON dbo.transactions.merchant_id = dbo.merchants.id
INNER JOIN dbo.employees ON dbo.transactions.employee_id = dbo.employees.id
WHERE
(dbo.transactions.date_purchased BETWEEN @minimumDate AND @maximumDate) AND
(@employee IS NULL or dbo.transactions.employee_id IN(@employee)) AND
(@po is null or dbo.transactions.purchase_order_number = @PO) AND (@merchant is null or dbo.transactions.merchant_id IN(@merchant)) AND
(@glCode is null or dbo.transactions.accounting_code IN(@glCode))
END
Without parameters 没有参数
CREATE PROCEDURE getData
AS
BEGIN
SET NOCOUNT ON;
SELECT dbo.transactions.date_purchased,
dbo.transactions.description,
dbo.transactions.purchase_order_number,
dbo.transaction_codes.transaction_code,
dbo.merchants.merchant,
dbo.transactions.amount,
dbo.employees.first_name + ' ' + dbo.employees.last_name AS employee
FROM dbo.transactions INNER JOIN
dbo.transaction_codes ON dbo.transactions.accounting_code = dbo.transaction_codes.id INNER JOIN
dbo.merchants ON dbo.transactions.merchant_id = dbo.merchants.id INNER JOIN
dbo.employees ON dbo.transactions.employee_id = dbo.employees.id
END
GO
Next thing I would try is a report with an embedded query to see if data is returned. 接下来,我将尝试执行一个带有嵌入式查询的报告,以查看是否返回了数据。 Perhaps, nothing will be returned but something might click for you along the way.
也许什么也不会退回,但是一路上可能会为您点击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.