Thursday, February 9, 2012

Accessing Null UDT's from TSQL

I created a UDT in C# that is working fine except when I request rows where the type is null.

If I use SELECT Film.ToString() FROM ImageData it works fine, or any property they return Null as expected

but if I use SELECT Film FROM ImageData it produces the error below

An error occurred while executing batch. Error message is: Data is Null. This method or property cannot be called on Null values.

I looked through all the examples in C# and my code matches the pattern for nulls exactly. Can anyone shead some light on what attribute I may have to add or method I should override which is not documented.

Could you please check the following topics in BOL?

http://msdn2.microsoft.com/es-es/library/ms131069.aspx

http://msdn2.microsoft.com/en-us/library/a8s4s5dz.aspx

When you query the column directly you should get either NULL for the NULL values or the binary representation of the UDT.

Can you check your code against the examples shown in the links above? There is a separate forum for SQL Server CLR that you can follow up also.

|||

This was a bugPlease see http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=125552

Cheers,

No comments:

Post a Comment