I have created .NET SQLCLR stored procedure, and built and published it on my local SQL Server.
In the .NET code I am using this connection string:
OleDbConnection connection = new OleDbConnection(
"provider=MSOLAP.7;data source=(local);initial catalog=AdventureWorksDW2014");
This .NET code contains a cube update query. Thus, the assembly needs to update the cube hosted on my local Analysis server.
When executing the SQLCLR stored procedure in SSMS I get the following error:
Msg 6522, Level 16, State 1, Procedure dbo.SqlStoredProcedure1, Line 0
[Batch Start Line 0] A .NET Framework error occurred during execution of user-defined routine or aggregate "SqlStoredProcedure1":
System.Security.SecurityException: Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. System.Security.SecurityException: at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.PermissionSet.Demand() at System.Data.Common.DbConnectionOptions.DemandPermission() at System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at StoredProcedures.SqlStoredProcedure1()
For some reason, the OleDb connection isn't working from the assembly. But, when debugged from Visual studio, the code runs perfectly fine and updates the cube.
Please share with me the potential fixes to the above error.
EXECUTE .. ATto issue any XMLA batch (andOPENROWSETfor MDX).