SSDT2017 Cstr() is returning #Error in the expression.

  • Hi all,

    The following code works:

    = Sum(2,"dsManagementArea")

    The following code is throwing an error:

    = CStr(Sum(2,"dsManagementArea"))

    The error message is:

    [rsRuntimeErrorInExpression] The Value expression for the textrun 'Textbox128.Paragraphs[0].TextRuns[0]' contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    The only sensible post I can find on this dates back to 2007 and references SQL2005.  I have SSDT2017 and SSMS 18.8.  I don't have an installation of Sequel on my machine.   Does anyone have any idea where to look to update the permissions so that I can pass something useful to my Admins as I am unlikely to have the necessary permissions on my own AD logon.

    I have tried Str() and that has the same issue.  I am hypothesising that all data conversion functions are not going to work.

    I am also happy to drop back down to native library functions if someone could advise on the syntax.

  • SSDT, if I remember right, allows for a lot of different things you can do with it including, but not limited to, SSRS, SSIS, SSAS, etc.

    Knowing what type of project you created in visual studio will help determine the correct syntax for datatype casting.

    For example, in SSRS you use CSTR like you did.  Quick google on your error though brought me to this site:

    https://social.msdn.microsoft.com/forums/sqlserver/en-US/31490332-c2f7-48a4-9928-29916ce002b4/request-for-the-permission-of-type-systemsecuritypermissionssecuritypermission-mscorlib

    Which indicates that you may need to set the permission set trust to full trust.

    This link goes into a bit more detail on it:

    https://social.msdn.microsoft.com/Forums/en-US/9af8f39a-9dc5-49ab-91af-2f64198c8477/ssrs-2008-custom-code-for-database-query?forum=sqlreportingservices

    If memory serves, even without SQL installed on your machine, SSDT installs the runtimes so you can do development testing.  Without the runtimes, you wouldn't be able to debug and test things.

    And fun things - even if the version of SQL you find in the help topic is old, it MAY still be relevant.  My approach is if the instructions sound reasonable for fixing my problem, make a backup of anything I am changing and test it.  Worst case, I roll back the changes and try to find help elsewhere.

    The above is all just my opinion on what you should do. 
    As with all advice you find on a random internet forum - you shouldn't blindly follow it.  Always test on a test server to see if there is negative side effects before making changes to live!
    I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply