简体   繁体   English

无法在VS2013报表设计器的SQL Server 2012中使用存储过程,总是返回空白?

[英]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.

相关问题 在应用程序代码与SQL中,带有OUTPUT参数的存储过程始终返回1 - Stored procedure with OUTPUT Parameter Always Returns 1 in Application Code vs SQL 想要从VS2012调试SQL Server 2008 R2存储过程-在SQL Server对象资源管理器中看不到数据库 - Want to debug SQL Server 2008 R2 stored procedure from VS2012 - Cannot see database in the SQL Server Object Explorer 在VS2013中使用报表设计器并在加载新报表时出现装配错误 - Using Report Designer in VS2013 and getting Assembly error loading new report VS2013 Pro中没有WPF设计器 - No WPF designer in VS2013 Pro VS2013中的表单设计器放大了? - Form designer in VS2013 Zoomed in? 在VS2013报表查看器中使用具有相同数据集的多个报表表创建报表 - Create Report in VS2013 Report Viewer with Multiple Report Tables that use the same Dataset VS2013无法使用SQL2012 SSIS自定义组件 - VS2013 not picking up SQL2012 SSIS Custom Components VS2013中没有显示设计器视图 - Designer view doesn't show up in VS2013 由于Fluent DLL无法看到VS2013 Designer - Unable to see the VS2013 Designer due to Fluent DLL Datareader在VS中没有返回结果,但Stored Procedure在Sql Server中返回多个结果集 - Datareader returns no results in VS yet Stored Procedure returns multiple result sets in Sql Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM