Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / CLR / November 2008

Tip: Looking for answers? Try searching our database.

TVF and SPs behave differently in Management Studio and from ADO

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Locke - 15 Nov 2008 15:44 GMT
Using SQL Server 2005 and .NET 3.5.

I have a SQL stored procedure [collection and validation of parameters]
which references some CLR table valued functions [some complex mathematics].
The table valued functions, in turn, call a SQL stored procedure doing
simple data retrieval [the data needed by the functions].

If I execute the stored procedure from a query pane in Management Studio,
everything always works exactly as expected (regardless of which parameters
I pass to the procedure).  Any missing parameters are defaulted to NULL in
the procedure.

However, if the stored procedure is executed from either MS Access (using
ADO) or from a .NET application (using ADO .NET) strange things happen......

Sometimes everything works as expected.  However, depending on which
parameters are supplied, I sometimes see a .NET exception complaining about
an out-of-range exception from deep in my CLR code.  I have got to a
position where supplying or omitting one of the parameters consistently
causes the error to occur (or not).  However, oddly, the exception comes
from a piece of my code which should not be affected by that parameter being
present or not.

I have checked and double-checked that the same parameters are being passed
in through ADO (both flavours) and in Management Studio.  As I said,
Management Studio works consistently, ADO works sometimes.

Gut feel says that the issue must either be to do with permissions (although
that's not what the error says) or to do with ADO doing something odd with
the parameters.

I realise that I have painted only a very general picture here.  However,
I'd welcome any pointers on where my search should start.

Thanks.
Sylvain Lafontaine - 15 Nov 2008 18:24 GMT
Make sure that the parameters that you are passing with ADO are really
exactly the same than with Management Studio (and the samae that you are
expecting) by printing them at the beginning of the SP.  You can also store
them in a table and try them by retrieving them from inside the SP.  This is
because some small differences (like a difference of precision in time) can
sometime remains hidden even when printing them because they are rounded up.

You can also directly set these parameters at the beginning of the SP and
see what does this gives when called from ADO. Using default values for
parameters will not necessarily gives you the same result because you might
have made some subtil error in the ADO code that is calling the SP.   Only
by explicitely setting them at the beginning of the SP that you can be sure
of the values that you are trying.

Signature

Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)

> Using SQL Server 2005 and .NET 3.5.
>
[quoted text clipped - 32 lines]
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.