Friday, March 23, 2012

Reporting services parameter([rsFieldReference] The Value expression for the...)

@.StartDate is a report parameter and CustomerNo is the field I want to render on the report,I want to combine the sql ,but it display the error message below when I preview the report.If I query in the design form and input the value of the parameter ,it run correctly .

Data sql:

declare @.sql nvarchar(4000)
declare @.sqlWhere nvarchar(4000)

set @.sql='select CustomerNo from table1 '
set @.sqlWhere=''

if @.StartDate<>''
begin
set @.sqlWhere =@.sqlWhere + ' StartDate=''' +@.StartDate + ''''
end

if ltrim(rtrim(@.sqlWhere))<>''
begin
set @.sqlWhere =' where ' + @.sqlWhere
end
set @.sql=@.sql+@.sqlWhere

exec sp_executeSQL @.sql

Error message:

[rsFieldReference] The Value expression for the textbox ‘CustomerNo’ refers to the field ‘CustomerNo’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.

I'm a beginner .Help me.

|||

Please give me a answer.

|||

I wrote a procedure and the problem is resolved.

No comments:

Post a Comment