Solved

Calling Custom Code in Reporting Services

Posted on 2004-08-18
4
948 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.

705 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