Execute a stored procedure inside textbox to get a localized text

柔情痞子 提交于 2019-12-11 04:47:37

问题


Is it possible to execute a stored procedure inside a textbox? We need this to localize our report.

For example, we have a stored procedure which returns the localized text for a given Key and a given LanguageId. I want to execute this stored procedure for every Label (Textbox) with a different key inside my report.

We are using SSRS 2008.


回答1:


I think you've got things a little mixed up, you can't "execute a sproc inside a textbox".

What you can do instead, is create a dataset that gets all required Key/Value pairs for your current language, something like this:

EXEC usp_GetReportLabels 'en-US'

/* Returns:

   Key       Val
  ---------  ------------
  lbl1       Firstname
  lbl2       Surname
  etc        etc
*/

On your textboxes you can use an expression utilizing the Lookup Function to retrieve the correct row from that dataset, and display the label value.

Note: You mention ssrs-2008 but not the ssrs-2008-r2 edition, I don't think the Lookup function is available in plain-2008. In that case you'll need to restructure your dataset(s) a bit to get the same effect. One solution would be to PIVOT the dataset and make the Keys into columns (the dataset will only contain one row in that case, so you can do First(Fields!lbl1.Value)). Bit of a workaround though.



来源:https://stackoverflow.com/questions/15918674/execute-a-stored-procedure-inside-textbox-to-get-a-localized-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!