0

我正在创建一个水晶报表,它将显示一些计数。只要我不使用日期参数来缩小结果范围,它就可以正常工作。当我尝试使用日期时,我的报告对所有计数都返回 0。

该报告使用具有以下 SQL 的命令对象(经过混淆处理,但语法相同)。

SELECT 
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_SUBMITTED IS NOT NULL) AS SUBMITTED,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate}) AS TOTALRECEIVED,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'A1') AS A1,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'A2') AS A2,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'A3') AS A3,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'A4') AS A4,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'A5') AS A5,
(SELECT COUNT(*) FROM REPORT_ WHERE DATE_RECEIVED BETWEEN {?StartDate} AND {?EndDate} AND STATUS_ LIKE 'OTHER') AS OTHER

如果我用命令本身中的静态值替换参数,它会完美运行......但是我使用日期参数所做的任何尝试都会导致它失败。我认为水晶报告提供的日期可能是ms sql server可以理解的格式。我试过铸造,但似乎没有任何效果。我怎样才能让我的日期参数工作?

4

1 回答 1

0

我终于想出了如何解决这个问题......这是人为错误。当提示输入参数的新值时,它以某种方式决定先询问结束日期,然后询问开始日期。我输入了错误的值,导致日期范围为空。我重新排列了参数请求,并输入了正确的值,并且它起作用了。

我有点惭愧,我花了这么长时间才解决,但我想我会发布这个,万一有人遇到了类似的问题。

于 2012-08-02T15:14:19.097 回答