Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 SQL Execution Error. No Error Message...

Author  Topic 

awarberg
Starting Member

2 Posts

Posted - 2009-10-05 : 15:37:44
Hi,

I have written a user defined function in .NET (C#). The function is called from a view with a couple of parameters and fetches additional information from other tables and views in the database, using a context connection.

I have introduced error handling various places in the code where I expect errors might happen.

In addition I have set up a try-catch statement around the body initial function call (my UDF) to catch any errors that might bubble up from subsequent calls.

My problem is that when I run the view I get the following errror message from Microsoft SQL Server Management Studio:

Executed SQL statement: SELECT ..., MyUdf(parameter1,...) FROM ...
Error Source: .NET SqlClient Data Provider
Error Message:

And yes, that is the problem! There is no error message so I am pretty much clueless to what this error is all about.

As I wrote earlier, I am catching any System.Exception's that my code might possibly generate at the top level, and throw a new exception which includes a message.

I have written several SQLCLR UDF and SP's before and not yet seen something like this.

Do you have some idea about this error condition and a solution?

The server is SQL Server 9.0.3310. The Management Studio is version 2008 with SP1. I wrote the codes in Visual Studio 2008 SP1.

I tried deploying the assembly with debug symbols and also as release.

There is no unmanaged code or external assemblies in the project.

The assembly permission set is SAFE.

Any advise is welcome.

Best regards
Andreas

awarberg
Starting Member

2 Posts

Posted - 2009-10-06 : 04:05:06
Hello again

I have found the bug!

By going through each row of the view (select top 1... top 2 etc) I found a set of values which triggered the error.

It turns out I am converting a double to a decimal and sometimes this conversion fails with a System.OverflowException.

I fixed the problem by simply handling the overflow exception.

Thanks for your time.

- Andreas
Go to Top of Page
   

- Advertisement -