Solved

Calling Custom Code in Reporting Services

Posted on 2004-08-18
4
934 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 143

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 143

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 143

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

860 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