<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Microsoft Application Blocks</title><link>http://forums.asp.net/122.aspx</link><description>Discuss the various Patterns &amp; Practices Application Blocks for ASP.NET 1.x.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3487715.aspx</link><pubDate>Sun, 01 Nov 2009 10:48:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3487715</guid><dc:creator>believer7</dc:creator><author>believer7</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3487715.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3487715</wfw:commentRss><description>&lt;p&gt;Replace this (SET @test = 5) with select @test=5&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3480509.aspx</link><pubDate>Tue, 27 Oct 2009 23:23:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3480509</guid><dc:creator>junfengd</dc:creator><author>junfengd</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3480509.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3480509</wfw:commentRss><description>&lt;p&gt;Since row sets will be returned before all output parameters for a stored procedure.&amp;nbsp;I guess that&amp;nbsp;you will need to either retrieve&amp;nbsp;or skip all row sets and then getting the output parameters.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3342536.aspx</link><pubDate>Wed, 12 Aug 2009 01:57:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3342536</guid><dc:creator>coderdave</dc:creator><author>coderdave</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3342536.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3342536</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;RealityO:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;As anyone ever fixed this issue? I&amp;#39;m currently having the same exact problem and there&amp;#39;s no solution in the thread.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try the ZipZango Database Library.&amp;nbsp;( &lt;a href="http://www.zipzango.com"&gt;www.zipzango.com&lt;/a&gt; )&amp;nbsp;I wrote it after continually running into the same type of issue. Download the demo. If you think it will work for you, drop me an email and I&amp;#39;ll arrange to get you a full copy for free. &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;-DG&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3311704.aspx</link><pubDate>Fri, 24 Jul 2009 18:18:02 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3311704</guid><dc:creator>ToddMoon</dc:creator><author>ToddMoon</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3311704.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3311704</wfw:commentRss><description>&lt;p&gt;There&amp;#39;s a simple but ugly workaround. Rather than use output parameters, select a second result set that contains one row with one column for each output variable you need. You will then have two result sets.&lt;/p&gt;&lt;p&gt;SELECT * FROM SomeTable --This is your normal select result&lt;/p&gt;&lt;p&gt;SELECT @Foo AS Foo, @Bar AS Bar, @Zap AS Zap --These are your &amp;quot;output parameters&amp;quot;&lt;/p&gt;&lt;p&gt;Of course, you would remove the actual output parameters from the stored procedure if doing this, and just use local variables.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If using a SqlDataReader you can use the NextResult() method to move to the next result. If using a SqlDataAdapter with a DataSet, you should get a second DataTable.&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3311689.aspx</link><pubDate>Fri, 24 Jul 2009 18:05:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3311689</guid><dc:creator>bcline</dc:creator><author>bcline</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3311689.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3311689</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I too am having the same problem.&amp;nbsp; Has anyone found a solution?&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/3221080.aspx</link><pubDate>Tue, 09 Jun 2009 18:43:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3221080</guid><dc:creator>RealityO</dc:creator><author>RealityO</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3221080.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=3221080</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I&amp;#39;m bumping a one year old thread:&lt;/p&gt;&lt;p&gt;&amp;nbsp;As anyone ever fixed this issue? I&amp;#39;m currently having the same exact problem and there&amp;#39;s no solution in the thread. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/2362152.aspx</link><pubDate>Fri, 16 May 2008 11:59:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2362152</guid><dc:creator>zirmandli</dc:creator><author>zirmandli</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2362152.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=2362152</wfw:commentRss><description>&lt;font size="2"&gt;
&lt;p&gt;Hi &lt;/p&gt;
&lt;p&gt;After declaring&amp;nbsp;variables&amp;nbsp;Execute your command&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;db.ExecuteNonQuery(dbCommandWrapper);&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;font size="2"&gt; objRetTest;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;p&gt;objRetTest= db.GetParameterValue(dbCommandWrapper, &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;Your variable name that u passes &amp;quot;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;if&lt;/font&gt;&lt;font size="2"&gt; (objRetTest== &lt;/font&gt;&lt;font color="#008080" size="2"&gt;DBNull&lt;/font&gt;&lt;font size="2"&gt;.Value) &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;font size="2"&gt; -1;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;else &lt;font color="#008000" size="2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#008000" size="2"&gt;
&lt;p&gt;// return output parameter values &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/2330877.aspx</link><pubDate>Wed, 30 Apr 2008 20:46:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2330877</guid><dc:creator>ToddMoon</dc:creator><author>ToddMoon</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2330877.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=2330877</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;szyder:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&lt;p&gt;try to use return @test &lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br /&gt;I am having the &lt;i&gt;exact &lt;/i&gt;same problem. This reply is not helpful because the stored procedure may have multiple output parameters. When using return, you will only be able to return one value.&lt;/p&gt;&lt;p&gt;EDIT: To clarify my problem, and to contradict the original post, the value of that output parameter is not NULL (DbNull.Value), it&amp;#39;s null (good old-fashioned C# null). Which implies that the framework is not assigning any value at all to the output parameter after execution of the command. Actually, when I set a value to the parameter &lt;i&gt;before&lt;/i&gt; executing the command, it gets replaced with null after execution. That&amp;#39;s even more strange.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;More Info: &lt;br /&gt;&lt;/p&gt;&lt;p&gt; If I execute the stored proc in Visual Studio and examine the results in the output window, it behaves exactly as expected. I see my query results, the value of my output parameter, and a @RETURN_VALUE of zero (the default if you don&amp;#39;t use a RETURN statement)&lt;br /&gt;&lt;br /&gt;If I don&amp;#39;t assign to the output parameter (which I named @ReturnCode) in the proc then I get &amp;lt;NULL&amp;gt; in the window. So, again, it&amp;#39;s working exactly as expected when executing in VS. It seems that the SqlClient library is to blame.&lt;/p&gt;&lt;p&gt;With SELECT and setting the output param: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;MacAddress&amp;nbsp;&amp;nbsp; &lt;br /&gt;------------ &lt;br /&gt;0002680117E7 &lt;br /&gt;No rows affected.&lt;br /&gt;(1 row(s) returned)&lt;br /&gt;&lt;b&gt;@ReturnCode = 0&lt;/b&gt;&lt;br /&gt;@RETURN_VALUE = 0&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br /&gt;With SELECT and not setting output param:&lt;/p&gt;&lt;p&gt;MacAddress&amp;nbsp;&amp;nbsp; &lt;br /&gt;------------ &lt;br /&gt;0002680117E7 &lt;br /&gt;No rows affected.&lt;br /&gt;(1 row(s) returned)&lt;br /&gt;&lt;b&gt;@ReturnCode = &amp;lt;NULL&amp;gt;&lt;/b&gt;&lt;br /&gt;@RETURN_VALUE = 0&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;From these results it&amp;#39;s clear that it &lt;i&gt;is &lt;/i&gt;being set when I set it to zero in the proc (Or returned as NULL if I don&amp;#39;t set it), but it&amp;#39;s always null when the SqlClient framework finishes executing it.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/2122271.aspx</link><pubDate>Mon, 21 Jan 2008 14:32:44 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2122271</guid><dc:creator>szyder</dc:creator><author>szyder</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2122271.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=2122271</wfw:commentRss><description>&lt;p&gt;try to use return @test &lt;/p&gt;</description></item><item><title>Interesting problem with getting OUTPUT parameters from SQL Server using C#</title><link>http://forums.asp.net/thread/2121993.aspx</link><pubDate>Mon, 21 Jan 2008 11:46:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2121993</guid><dc:creator>gilberk</dc:creator><author>gilberk</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2121993.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=122&amp;PostID=2121993</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;I have the following SP:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Create procedure dbo.example&lt;/p&gt;&lt;p&gt;(&lt;/p&gt;&lt;p&gt;@test INT OUTPUT&lt;/p&gt;&lt;p&gt;)&lt;/p&gt;&lt;p&gt;AS&lt;/p&gt;&lt;p&gt;BEGIN&lt;/p&gt;&lt;p&gt;SET @test = 5&lt;/p&gt;&lt;p&gt;SELECT * from Users&lt;/p&gt;&lt;p&gt;END&lt;/p&gt;&lt;p&gt;GO&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;and when I try calling it from C# using an SqlCommand with adding an output parameter and getting it&amp;#39;s value, I get that the value is NULL. (I should mention that I use ExecuteReader)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;However,&amp;nbsp; if I alter the SP and remove the select line, the c# code works and returns the value 5.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>