2012-01-29 3 views
0

embed VB 코드에서 데이터베이스를 열려고합니다. MyConnection.Open()에 내가 말하는 오류가SQL Reporting Services 임베디드 코드를 사용하여 데이터베이스에 액세스하려고 시도했습니다.

Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. C:\Users\tedpottel\Documents\Visual Studio

보고서 내 데이터 소스가 Data Source=(local);Initial Catalog=bw
VB 코드는 다음과 같습니다

Public Function TestData () As Boolean 
Dim MyConnection As System.Data.SQLClient.SqlConnection 
Dim MyCommand As System.Data.SQLClient.SqlCommand 
MyConnection = New System.Data.SQLClient.SqlConnection("server=(local);Initial Catalog=bw") 
MyConnection.Open() 
MyConnection.Close() 
return True 
End Function 

답변

2
"System.Data.SqlClient.SqlClientPermission"에 대한 구글의

첫 번째 결과 :

Hi Joost,

Based on your description, this issue was probably related to the Code Access Security. Please refer to the following articles to configure the assembly to make sure it is set to fulltrust. Request for the permission of type 'SecurityPermission' failed: http://blogs.msdn.com/b/floditt/archive/2009/08/10/request-for-the-permission-of-type-securitypermission-failed.aspx

완전 신뢰로 실행되도록 코드를 구성하는 방법에 대한 정보는 링크를 클릭하십시오.

The tool CasPol.exe (part of the .Net SDK) will help you to identify the CodeGroup that the System.Security assembly belongs to. In the GAC folder of this assembly I did a CasPol –rsg (resolvesGroup) on this assembly:

Now we can see that this assembly belongs to the Microsoft_Strong_Name (line 3 in the CodeGroup excerpt) and is configured for FullTrust. With the –rsp (resolvesPermissions) you can visualize all permissions that are granted to this assembly (as defined in the FullTrust named PermissionSet):

When the exception was raised, this assembly was configured to ‘Nothing’ (line 3 of the NamedPermissionSets excerpt). The problem was resolved by granting this assembly FullTrust.