Share This!

Saturday, November 19, 2011

Using Return Values From Stored Procedures in C#.NET

Ok, let's say you have a stored procedure that returns a value.

Now lets say you want to test it in SQL Server Management Studio...

This gives us a value of 1, as expected.

Now if we want to call this from C#, there is a little trick we have to play with Parameters.

Note the trick we had to play here (line 19) to access the return value after the procedure runs.  At first, I tried using:
...but that always yielded a value of -1.

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

No comments:

Post a Comment

Contact Us


Email *

Message *