2012-01-29 14 views
0

埋め込み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" のためのGoogleで

最初の結果:

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.

関連する問題