Solved

Calling Custom Code in Reporting Services

Posted on 2004-08-18
4
914 Views
Last Modified: 2012-08-14
Hi,

I'm trying to call a custom function in SQL Server Reporting services. The code works fine in a VB.NET window application but when run through Reporting Services I get the following error:

"Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed."

I think it is a security configuration/setting... possibly something with IIS?

Anyone have any ideas? The code is as below. Thanks.


Public Function FHNameLookUp(FNumber As String) As String

        Dim conTemp As New System.Data.SqlClient.SqlConnection("Integrated Security=SSPI;data source=local;initial catalog=Temp")
        Dim cmdTemp As New System.Data.SqlClient.SqlCommand("SELECT Name FROM Finance WHERE FinanceID = " + FNumber, conTemp)
        Dim drTemp As System.Data.SqlClient.SqlDataReader
        Dim FHName As String

        Try
            cmdTemp.Connection.Open()
            drTemp = cmdTemp.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
            drTemp.Read()
            FName = drTemp.GetString(0)
            drTemp.Close()
            conTemp.Close()
        Catch E As System.Exception
            System.Console.Write("Cannot retrieve name")
        End Try
        Return FName

End Function
0
Comment
Question by:DavidDunn
  • 3
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 11838815
I have seen this error message also on Windows Application: when the application started from a source that was not trusted by the .net engine... I solved the problem by starting the application from a local drive instead from the network drive, and read later that one could specify/manage trusted sources for .net applications (but no details :-(
I have not yet found it, but maybe this helps you already...
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 11838824
http://www.dotnet247.com/247reference/msgs/38/190410.aspx

reading, I would try to change the Report Service to run under a domain account...

Hope this helps
0
 

Author Comment

by:DavidDunn
ID: 11843190
Hi,

It appears that it was the security setting in the Reporting Services config file (as described) in the links above.

Also, I was calling an external assembly (SQLClient) and so I needed to assert permissions as below:

  Dim permission As New System.Data.SqlClient.SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted)
  permission.Assert()      

Thanks.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11849569
Glad I could help, this way I found some answers myself (so I due YOU some points :-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now