Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2008 > BOOK: Professional Microsoft SQL Server 2008 Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Microsoft SQL Server 2008 Programming
This is the forum to discuss the Wrox book Professional Microsoft SQL Server 2008 Programming by Robert Vieira; ISBN: 9780470257029
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Microsoft SQL Server 2008 Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 6th, 2010, 11:10 AM
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()
.
Reply With Quote
  #2 (permalink)  
Old August 6th, 2010, 02:04 PM
Registered User
 
Join Date: Jul 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Found the problem

When I moved forward in the book to the "Custom Data Types" section Mr. Vieira has us download the code from this site, so I did. At that point I decided to examine the ExampleAggregate code to see if it would display the same error, and alas it worked just fine. On comparison between the code in the sample download and that printed in the book I found the problem.

On page 324 is a line that I thought looked strange when I read it, and then even more strange when I typed it into the C# struct. That line reads:
Code:
SqlContext.Pipe.Send("WARNING: Aggregate values exist and were ignored");
You see, the odd thing is there is nothing in the function to determine that condition. Plus, there probably is something that has to do with checking on the data table which from the error message appears to be prohibited by this type of assembly. Anyway, that line is not present in the downloaded code, which is why it runs as expected.

Donny Buckman
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB.Connection user-defined type not defined Wall st Guru Excel VBA 2 March 26th, 2014 04:44 PM
User-Defined Type Error - Re: File Dialog Coby Access VBA 1 January 16th, 2008 09:42 AM
User-defined type not defined (Icecream.mdb) dloren01 BOOK: Beginning Access VBA 0 June 22nd, 2005 11:36 PM
User Defined Error Messages pvasudevan SQL Server 2000 0 March 18th, 2004 08:46 AM
User defined Aggregate function to calculate skew akmhasan Oracle 0 July 20th, 2003 01:44 AM



All times are GMT -4. The time now is 05:07 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.