<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx</link><description>If you’ve been wondering why you are not able to access stored procedure return values from TableAdapter, here’s the solution for you. I will use tbTasks table and spInsertTask stored procedure to demonstrate the solution. You can see definitions for</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#693138</link><pubDate>Wed, 09 Aug 2006 13:55:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:693138</guid><dc:creator>lusay</dc:creator><description>Good</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#709780</link><pubDate>Mon, 21 Aug 2006 01:39:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:709780</guid><dc:creator>Phil</dc:creator><description>I have reviewed your example and ask if you could explain how one does this in a web application. I have been pulling out my hair trying to fix this. I have been stuck on this for an entire day. My sql query works fine when tested even using the table adapter &amp;quot;preview data&amp;quot;. However, when I try to pull the result into a variable to be displayed in a textbox or any object for that matter on a web form, I experience the problems you detailed in your example. I would greatly appreciate a &amp;quot;translation&amp;quot; of your solution as it relates to a web form. Thank you for sharing your knowledge.
&lt;br&gt;</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#710948</link><pubDate>Mon, 21 Aug 2006 20:07:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:710948</guid><dc:creator>youngjoo</dc:creator><description>Phil,&lt;br&gt;&lt;br&gt;Are you having problem using Typed Dataset in your web application or is the problem specific to accessing return values from stored procedures in your web application? &amp;nbsp;If you are having trouble using Typed Dataset in generation, there's a great tutorial where you can learn how to build 3-tier application in ASP.NET. &amp;nbsp;Please check out &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnettut/html/aspnet_tutorial01_dataaccesslayer_vb.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnettut/html/aspnet_tutorial01_dataaccesslayer_vb.asp&lt;/a&gt; and following series articles.&lt;br&gt;&lt;br&gt;- YoungJoo</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#714583</link><pubDate>Wed, 23 Aug 2006 16:26:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:714583</guid><dc:creator>Caesar G</dc:creator><description>Hi!
Your post is really interesting. What I have found is that although the stored procedure works great, is doesn't update the dataset.
After calling the insertTask function and looking for the newly created row in the dataset you realize that it does not exist.
If you have a DataGridView connected to the dataset through a databinding component it will not update the view contents.
I have to re-fill the dataset with the table adapter in order to update the DataGridView. With a small group of data that's not a problem, but with large amounts of information that would generate performance issues.
Calling the reset bindings and some other methods in the databinding (endEdit) component don't work either.
Do you have any idea how to refresh the dataset and the datagridview once the row is inserted via the InsertTask function? I'll really appreciate your comments.
</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#749241</link><pubDate>Mon, 11 Sep 2006 09:34:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:749241</guid><dc:creator>Lothan</dc:creator><description>I have read your explaination to retrieve the procedure return value from TableAdapter...I've done almost the same, but in my DataSet.cs (where I should write that partial class of TableAdapter), It does not find any definition for CommandCollection and I can't find why!!&lt;br&gt;In DataSet.Designer.cs, InitCommandCollection(), I found the CommandCollection Index I need to use and it's there!&lt;br&gt;I would be very glad if you can give me some hint or clue, which where I can find the answer of the error, saying there is no definition for CommandCollection! and so in my form, saying there is no definition for the method I wrote in that partial class of DataSet Designer..!&lt;br&gt;Thank you again.</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#768279</link><pubDate>Sat, 23 Sep 2006 22:27:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:768279</guid><dc:creator>Tpm Corrigan</dc:creator><description>Why not just go with the flow and change the last line of the stored procedure from

return scope_identity()

to 

select scope_identity() ?

Then ExecuteScalar returns the desired result.</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#770645</link><pubDate>Mon, 25 Sep 2006 18:44:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:770645</guid><dc:creator>Ben</dc:creator><description>I too have been searching for this solution.  Your article provides a good method to retrieve the return code.  The only thing that concerns me is accessing the command collection by an index.  It looks like the Typed Dataset adds commands to the collection alphabetically with the exception of the default method.  If I refer to the command by it's index, and latter add a method to the adapter, the index of my command object could change, right?  Is there a different/better way to refer to it without the subtle danger of methods getting reordered in the command collection?

Thanks!</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#770685</link><pubDate>Mon, 25 Sep 2006 19:18:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:770685</guid><dc:creator>hamed</dc:creator><description>Hi!

Do you have any workarounds, when using QueriesTableAdapter and not the TableAdapter?
In this case, the generated class file doesnt have the stored procedure's CommandCollection[x].Parameters[y].Value property, so i cannot create a proper GetReturnValue object like the one in your solution.</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#774638</link><pubDate>Thu, 28 Sep 2006 03:09:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:774638</guid><dc:creator>John Miller</dc:creator><description>TasksDataset.cs &lt;BR&gt;&lt;BR&gt;In response to the above error -- you should cast the parameter class as the return value. &amp;nbsp;Here is what works: &lt;BR&gt;&lt;BR&gt;[ C# ] &lt;BR&gt;&lt;BR&gt;namespace WindowsApplication1.TasksDatasetTableAdapters { &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp;public partial class tbTasksTableAdapter &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp;{ &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public object GetReturnValue(int commandIndex) &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return ((System.Data.SqlClient.SqlParameter)this.CommandCollection[commandIndex].Parameters[0]).Value; &lt;BR&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;nbsp;} &lt;BR&gt;&lt;BR&gt;} &lt;BR&gt;&lt;BR&gt;</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#781006</link><pubDate>Mon, 02 Oct 2006 19:43:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:781006</guid><dc:creator>youngjoo</dc:creator><description>&lt;p&gt;Lothan,&lt;/p&gt;
&lt;p&gt;Could you please copy and paste your partial class code?&lt;/p&gt;
&lt;p&gt;- YoungJoo&lt;/p&gt;
</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#827577</link><pubDate>Sun, 15 Oct 2006 07:22:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:827577</guid><dc:creator>JungleBoy</dc:creator><description>&lt;p&gt;YoungJoo,&lt;/p&gt;
&lt;p&gt;Another solution could be add a new line at end of stored procedure using clause SELECT, like this: SELECT SCOPE_IDENTITY().&lt;/p&gt;
&lt;p&gt;Then, the method ExecuteScalar return the correct value.&lt;/p&gt;
</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#1277929</link><pubDate>Thu, 14 Dec 2006 00:44:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1277929</guid><dc:creator>geblack</dc:creator><description>&lt;p&gt;OK, select scope_identity is all well and fine for sql server, how do you go about getting the new pk value when using sqlce? Since batch statements are not allowed (and there is not scope_identity function in sqlce even if you could batch).&lt;/p&gt;
&lt;p&gt;I really don't want to have to ride an event to issue another statement to sqlce to get the new value using @@identity.&lt;/p&gt;
</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#3976925</link><pubDate>Fri, 20 Jul 2007 18:55:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3976925</guid><dc:creator>Ray</dc:creator><description>&lt;p&gt;I am particularly interested in Ben's question about the Procedure Index. &amp;nbsp;Is there a more symbolic way to accomplish the same thing?&lt;/p&gt;
&lt;p&gt;Or alternatively could one use a For Next loop comparing the Command.Text to the known procedure name.&lt;/p&gt;
&lt;p&gt;For each obj in theCommands&lt;/p&gt;
&lt;p&gt; if obj.CommandText = &amp;quot;dbo.sp_InsertTask&amp;quot; then&lt;/p&gt;
&lt;p&gt; &amp;nbsp; blah, blah&lt;/p&gt;
&lt;p&gt; &amp;nbsp; return&lt;/p&gt;
&lt;p&gt; end if&lt;/p&gt;
&lt;p&gt;next&lt;/p&gt;
&lt;p&gt;Return Error&lt;/p&gt;</description></item><item><title>re: How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#4319012</link><pubDate>Fri, 10 Aug 2007 12:00:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4319012</guid><dc:creator>You really saved my days with this one.</dc:creator><description>&lt;p&gt;I was on this problem for nearly 2 days.&lt;/p&gt;
&lt;p&gt;consider my situation when you get stuck for inserting a record for that long.&lt;/p&gt;
&lt;p&gt;I think asp.net guys should put this in their articles section. &lt;/p&gt;
&lt;p&gt;Thanks again ...&lt;/p&gt;</description></item><item><title>tableadapter sql variable</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#8413985</link><pubDate>Mon, 21 Apr 2008 10:21:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8413985</guid><dc:creator>tableadapter sql variable</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://julio.dishtvnews.com/tableadaptersqlvariable.html"&gt;http://julio.dishtvnews.com/tableadaptersqlvariable.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>smart retrieve</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#8484006</link><pubDate>Sat, 10 May 2008 19:30:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8484006</guid><dc:creator>smart retrieve</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://lillie.freemedianewsnetwork.info/smartretrieve.html"&gt;http://lillie.freemedianewsnetwork.info/smartretrieve.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Smart Client Data How to retrieve stored procedure return values from | Hair Growth Products</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#9713829</link><pubDate>Tue, 09 Jun 2009 11:17:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9713829</guid><dc:creator> Smart Client Data How to retrieve stored procedure return values from | Hair Growth Products</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://hairgrowthproducts.info/story.php?id=5475"&gt;http://hairgrowthproducts.info/story.php?id=5475&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Smart Client Data How to retrieve stored procedure return values from | fix my credit</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx#9764609</link><pubDate>Wed, 17 Jun 2009 05:11:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9764609</guid><dc:creator> Smart Client Data How to retrieve stored procedure return values from | fix my credit</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://fixmycrediteasily.info/story.php?id=17155"&gt;http://fixmycrediteasily.info/story.php?id=17155&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>