View Single Post
  #1 (permalink)  
Old August 6th, 2010, 10:10 AM
Monchkrit Monchkrit is offline
Registered User
 
Join Date: Jul 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Runtime Error on User Defined Aggregate

I am getting a runtime error on the sample code from Chapter 10. The system assembles and creates the User Defined Aggregate, when when I go to run it I get a nasty error. The output is pasted below. Can you please help to me figure out how to get around this problem?

Thank you,
Donny Buckman

GroupKey Product
----------- ----------------------
Msg 6522, Level 16, State 2, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "Product":
System.InvalidOperationException: Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.
System.InvalidOperationException:
at System.Data.SqlServer.Internal.ClrLevelContext.Che ckSqlAccessReturnCode(SqlAccessApiReturnCode eRc)
at System.Data.SqlServer.Internal.ClrLevelContext.Get CurrentContext(SmiEventSink sink, Boolean throwIfNotASqlClrThread, Boolean fAllowImpersonation)
at Microsoft.SqlServer.Server.InProcLink.GetCurrentCo ntext(SmiEventSink eventSink)
at Microsoft.SqlServer.Server.SmiContextFactory.GetCu rrentContext()
at Microsoft.SqlServer.Server.SqlContext.get_CurrentC ontext()
at Microsoft.SqlServer.Server.SqlContext.get_Pipe()
at Product.Terminate()
.