Interesting problem with getting OUTPUT parameters from SQL Server using C#

 I have the following SP:

 

Create procedure dbo.example

(

@test INT OUTPUT

)

AS

BEGIN

SET @test = 5

SELECT * from Users

END

GO

 

 

and when I try calling it from C# using an SqlCommand with adding an output parameter and getting it's value, I get that the value is NULL. (I should mention that I use ExecuteReader)

However,  if I alter the SP and remove the select line, the c# code works and returns the value 5.

 

Read More

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s