Link to home
Start Free TrialLog in
Avatar of niceguy971
niceguy971

asked on

SSRS 2008 Report is converting varchar Parameters to int

I noticed that  SSRS 2008 Report was converting a text parameter in the report to an integer during execution.

It's possible to cast text parameter to a varchar like below. Looks like it resolves the issue.

Is there a better way to fix this issue??

DECLARE @myParam int //  text parameter in the report  converting  to an integer during //execution.
SET @myParam=125

declare @mStr varchar(50)

SELECT @mStr=CAST(@myParam as varchar(10))
print @mStr ----> 125
Avatar of DcpKing
DcpKing
Flag of United States of America image

What are you doing with the parameter when you notice the conversion ? For example, are you trying to do something like Parameters!txtParam.value + " is a string" and getting a type-mismatch error ? Or not getting an error with Parameters!txtParam.value + 16 ?  

There must be a reason for SSRS thinking that you really mean it to be a int, not a text: are you actually passing it an int, by any chance? If so, type it as an int, and then use it as a text with the CStr function.

hth

Mike
Avatar of niceguy971
niceguy971

ASKER

Please check the link
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/0a07b6f6-f427-48ad-af84-4da84a63af3f/

It describes the same issue.  I enter RS report parameter (when it prompts) when i run report
(and this parameter was defined as TEXT...)  but RS report treats my parameter as string.

Any comments??

Thanks
Sorry .....typo...but RS report treats my parameter as  Integer !!!
ASKER CERTIFIED SOLUTION
Avatar of DcpKing
DcpKing
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mike, Your question "What exactly do you mean by "RS treats my parameter as integer" ?"--

I was not able to create new dataset in RS Report..I was getting an error in RS report (design time)..even the same query (the code) worked fine in Sql Server Management Studio.
The reason is described in the article above (the link above):  RS report  "..was converting a text parameter in the report to an integer.."... in my case during design time.  I use the following to resolve this issue:

declare @mStr varchar(50)
SELECT @mStr=CAST(@myParam as varchar(10))

I did not use CStr() to fix this issue.
I'm closing this question.
Thanks
Thanks for explaining! I assumed that it was a runtime thing. Good luck

Mike