简体   繁体   English

简单的where子句SSRS 2005参数不起作用

[英]simple where clause SSRS 2005 parameter not working

this should be a simple thing but I've spent hours to no avail. 这应该是一件简单的事情,但是我已经花了几个小时没有用。 Basically, I need to look up a salesrep # in a SQL database using the user's Window's user id. 基本上,我需要使用用户的Window的用户ID在SQL数据库中查找salesrep#。 The format of the user id is "Norstar\\kjones" and I need the "kjones" portion of it. 用户ID的格式为“ Norstar \\ kjones”,我需要其中的“ kjones”部分。

using the split function, I am able to pull just the 'kjones' part out: 使用split函数,我可以仅将'kjones'部分拉出:

split(User!UserID,"\").GetValue(1)

I've created a parameter called SlsmnNum and created a dataset to be used to look up the salesrep # using the user id (the slsm_num field is a varchar, not an integer): 我创建了一个名为SlsmnNum的参数,并创建了一个数据集,该数据集用于使用用户ID(slsm_num字段是varchar,而不是整数)来查找salesrep#:

select slsm_num from Salesman_Msid where slsm_msid = ''' + split(User!UserID,"\").GetValue(1) + '''

However, I get no results. 但是,我没有结果。 How can I get the select to work? 我如何才能使选择工作?

alternatively, I tried the following: in parameter SlsmnNum, I set the default to an expression using: split(User!UserID,"\\").GetValue(1) and this returns 'kjones', as expected. 或者,我尝试了以下操作:在参数SlsmnNum中,使用以下命令将默认值设置为表达式: split(User!UserID,"\\").GetValue(1) ,这将按预期返回'kjones'。

I created a SECOND parameter (which is positioned BELOW the SlsmnNum parameter), SlsmnNum2 , that has a default (and an available) value using a query, which is a dataset containing the following select statement: 我使用查询创建了一个SECOND参数(位于SlsmnNum参数下方) SlsmnNum2 ,该参数具有默认值(和可用值),该查询是一个包含以下select语句的数据集:

select slsm_num from Salesman_Msid where slsm_msid = (@SlsmnNum)

When I run the query on the Data tab, when I type in 'kjones' into the parameter box, it returns '1366', the salesrep # I'm expecting. 当我在“数据”选项卡上运行查询时,在参数框中输入“ kjones”时,它将返回“ 1366”,即我期望的salesrep#。

But, when I Preview the report, all I get in SlsmnNum2 box is Select a Value and nothing is there (it should return '1366'). 但是,当我预览报表时,在SlsmnNum2框中获得的所有内容都是“ Select a Value ,没有任何内容(应该返回“ 1366”)。

Any help would be greatly appreciated! 任何帮助将不胜感激!

Try your first approach with Query Text as 尝试使用“ 查询文本”作为第一种方法

="select slsm_num from Salesman_Msid where slsm_msid = '" & split(User!UserID,"\").GetValue(1) & "'"

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM