Solved

Calling Custom Code in Reporting Services

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

815 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

9 Experts available now in Live!

Get 1:1 Help Now