Previous Thread:   Problem setting up ODBC DSN for SQL Server Express

2/23/2006 5:13:31 PM    RETURN value from CLR SP
Ah, how does one set the RETURN value in a CLR SP or is this not supported?  
  
The compiler does not like the AS SQLINT32 code...  
  
--  
  
____________________________________  
  
William (Bill) Vaughn  
  
Author, Mentor, Consultant  
  
Microsoft MVP  
  
INETA Speaker  
  
www.betav.com/blog/billva  
  
www.betav.com  
  
Please reply only to the newsgroup so that others can benefit.  
  
This posting is provided "AS IS" with no warranties, and confers no rights.  
  
__________________________________



2/23/2006 5:22:45 PM    Re: RETURN value from CLR SP
So, what if I change the template to Function and return a SqlInt32? Does  
  
this confuse the compiler? I'm about to check.  
  
--  
  
____________________________________  
  
William (Bill) Vaughn  
  
Author, Mentor, Consultant  
  
Microsoft MVP  
  
INETA Speaker  
  
www.betav.com/blog/billva  
  
www.betav.com  
  
Please reply only to the newsgroup so that others can benefit.  
  
This posting is provided "AS IS" with no warranties, and confers no rights.  
  
__________________________________  
  
"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message  
  
news:OUAmH%23NOGHA.2624@TK2MSFTNGP12.phx.gbl...

2/23/2006 5:24:44 PM    Re: RETURN value from CLR SP
Apparently, it does not matter. So now the question remains, why did the SP  
  
template use a SUB instead of a function?  
  
--  
  
____________________________________  
  
William (Bill) Vaughn  
  
Author, Mentor, Consultant  
  
Microsoft MVP  
  
INETA Speaker  
  
www.betav.com/blog/billva  
  
www.betav.com  
  
Please reply only to the newsgroup so that others can benefit.  
  
This posting is provided "AS IS" with no warranties, and confers no rights.  
  
__________________________________  
  
"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message  
  
news:OUAmH%23NOGHA.2624@TK2MSFTNGP12.phx.gbl...

2/24/2006 12:14:37 AM    Re: RETURN value from CLR SP
"William \(Bill\) Vaughn" <billvaRemoveThis@nwlink.com> wrote in  
  
news:eKQMZEOOGHA.3284@TK2MSFTNGP14.phx.gbl:  
  
Bill,  
  
I don't know what you are doing but the following VB code both compiles  
  
correct and deploys without a hitch.  
  
Partial Public Class StoredProcedures  
  
<SqlProcedure()> _  
  
Public Shared Function vbProc() As SqlInt32  
  
Return 999  
  
End Function  
  
End Class  
  
What are you seeing?  
  
Niels  
  
--  
  
**************************************************  
  
* Niels Berglund  
  
* http://staff.develop.com/nielsb  
  
* nielsb@no-spam.develop.com  
  
* "A First Look at SQL Server 2005 for Developers"  
  
* http://www.awprofessional.com/title/0321180593  
  
**************************************************

2/24/2006 2:57:19 AM    Re: RETURN value from CLR SP
Bill,  
  
Here's a Csharp example of a CLR SP that returns a value  
  
(and has an output parameter in addition)  
  
using System;  
  
using System.Data;  
  
using System.Data.SqlClient;  
  
using System.Data.SqlTypes;  
  
using Microsoft.SqlServer.Server;  
  
public partial class StoredProcedures  
  
{  
  
[Microsoft.SqlServer.Server.SqlProcedure]  
  
public static SqlInt32 ReturnInts(ref SqlInt32 n)  
  
{  
  
SqlInt32 save_n = n;  
  
n = n/2;  
  
return save_n;  
  
}  
  
};  
  
Then this repro goes as follows:  
  
declare @i int  
  
set @i = 100  
  
declare @returnval int  
  
exec @returnval = ReturnInts @i output  
  
select @returnval, @i  
  
----------- -----------  
  
100         50  
  
Steve Kass  
  
Drew University  
  
William (Bill) Vaughn wrote:

2/24/2006 8:37:10 AM    Re: RETURN value from CLR SP
I was initially confused by the template that thought a SP should be  
  
prototyped as a Sub and not a function.  
  
--  
  
____________________________________  
  
William (Bill) Vaughn  
  
Author, Mentor, Consultant  
  
Microsoft MVP  
  
INETA Speaker  
  
www.betav.com/blog/billva  
  
www.betav.com  
  
Please reply only to the newsgroup so that others can benefit.  
  
This posting is provided "AS IS" with no warranties, and confers no rights.  
  
__________________________________  
  
"Niels Berglund" <nielsb@develop.com> wrote in message  
  
news:Xns977453D6ADCE9nielsbdevelopcom@207.46.248.16...