<?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>Smart Client Data</title><link>http://blogs.msdn.com/smartclientdata/default.aspx</link><description>This blog describes some of the Data features specific to Smart Clients.  This includes Windows Forms, Devices and Visual Studio Tools for Office.  The Smart Client Data team, AKA VB Data, is responsible for features such as the Data Sources Window, Typed DataSet Designer and the data wizards such as the DataAdapter, Command and other wizards.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to retrieve stored procedure return values from TableAdapter</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx</link><pubDate>Wed, 09 Aug 2006 13:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:693113</guid><dc:creator>youngjoo</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/693113.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=693113</wfw:commentRss><description>&lt;SPAN style="FONT-SIZE: 1pt; COLOR: #4f81bd; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;&lt;?xml:namespace prefix = w ns = "urn:schemas-microsoft-com:office:word" /&gt;&lt;w:sdtPr&gt;&lt;/w:sdtPr&gt;&lt;w:Sdt id=89512082 title="Post Title" Xpath="/ns0:BlogPostInfo/ns0:PostTitle" Text="t" StoreItemID="X_D8252CAC-FC90-4EA4-B323-C9DC343FCAE4" DocPart="6E6AC78C0EA24EF3BC59DB37D20D8A66"&gt;&lt;/SPAN&gt;&lt;/w:Sdt&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;If you’ve been wondering why you are not able to access stored procedure return values from TableAdapter, here’s the solution for you.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;I will use &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasks &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;table and &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;spInsertTask &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;stored procedure to demonstrate the solution.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can see definitions for both below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;TABLE&lt;/SPAN&gt; dbo&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;tbTasks&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: gray; mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;intID &lt;SPAN style="COLOR: blue"&gt;INT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NULL&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;IDENTITY&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;1&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt;1&lt;SPAN style="COLOR: gray"&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;strName &lt;SPAN style="COLOR: blue"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;100&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;intPriority &lt;SPAN style="COLOR: blue"&gt;INT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;dtDueDate &lt;SPAN style="COLOR: blue"&gt;DATETIME&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: gray"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: gray; mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Courier New" size=2&gt;----------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;PROCEDURE&lt;/SPAN&gt; dbo&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;spInsertTask&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;@strName &lt;SPAN style="COLOR: blue"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;200&lt;SPAN style="COLOR: gray"&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;@intPriority &lt;SPAN style="COLOR: blue"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;@dtDueDate &lt;SPAN style="COLOR: blue"&gt;DATETIME&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;INSERT&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt; tbTasks &lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;strName&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt; intPriority&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt; dtDueDate&lt;SPAN style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;VALUES&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;@strName&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt; @intPriority&lt;SPAN style="COLOR: gray"&gt;,&lt;/SPAN&gt; @dtDueDate&lt;SPAN style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: gray; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;RETURN&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: fuchsia"&gt;SCOPE_IDENTITY&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;Notice that &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasks &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;has an identity column named &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;intID&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Also, stored procedure &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;spInsertTask &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;returns the new identity column value using &lt;/FONT&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms190315(d=ide).aspx"&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: windowtext; LINE-HEIGHT: 115%; TEXT-DECORATION: none; mso-bidi-font-size: 11.0pt; text-underline: none"&gt;&lt;FONT face="Courier New"&gt;SCOPE_IDENTITY()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Georgia&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Knowing this new identity value is extremely useful on the client side.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;Create a new Typed Dataset called &lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset&lt;/I&gt; and add &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasks&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Also, add a new query to &lt;I style="mso-bidi-font-style: normal"&gt;tbTasksTableAdapter&lt;/I&gt; using &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;spInsertTask&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; stored procedure.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When adding a new query, choose ‘A single value’ option.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Georgia&gt;&lt;IMG src="http://blogs.msdn.com/photos/youngjoo/images/693130/original.aspx"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Georgia&gt;&lt;IMG src="http://blogs.msdn.com/photos/youngjoo/images/693131/original.aspx"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;At this point, you probably would expect that following code would assign the new identity value returned by &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;spInsertTask&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; stored procedure to &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;returnValue&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; variable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[ VB ]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taTasks &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; TasksDatasetTableAdapters.tbTasksTableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskName &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskPriority &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskDueDate &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Date&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; returnValue &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: green; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskName = &lt;SPAN style="COLOR: maroon"&gt;"Test"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskPriority = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskDueDate = Now()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;returnValue = taTasks.InsertTask(TaskName, TaskPriority, TaskDueDate)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[C#]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TasksDatasetTableAdapters.&lt;SPAN style="COLOR: teal"&gt;tbTasksTableAdapter&lt;/SPAN&gt; taCustomers = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; WindowsApplication1.TasksDatasetTableAdapters.&lt;SPAN style="COLOR: teal"&gt;tbTasksTableAdapter&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: teal; mso-no-proof: yes"&gt;String&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskName;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;int&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskPriority;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: teal; mso-no-proof: yes"&gt;DateTime&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskDueDate;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;int&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; returnValue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskName = &lt;SPAN style="COLOR: maroon"&gt;"Test"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskPriority = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskDueDate = System.&lt;SPAN style="COLOR: teal"&gt;DateTime&lt;/SPAN&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face="Courier New" size=2&gt;returnValue = taCustomers.InsertTask(taskName, taskPriority, taskDueDate);&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Georgia&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;However, running above code results in &lt;I style="mso-bidi-font-style: normal"&gt;System.InvalidOperationException&lt;/I&gt; during run-time for VB and “&lt;I style="mso-bidi-font-style: normal"&gt;Cannot implicitly convert type 'int?' to 'int'&lt;/I&gt;.” compile error for C#.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you look at what actually gets returned by &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasksTableAdapter.InsertTask()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; function, you will understand why above code does not work.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can find the function from the generated Typed Dataset code, &lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset.Designer.vb&lt;/I&gt; / &lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset.Designer.cs&lt;/I&gt; in this case.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[ VB ]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Public&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Overridable&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Overloads&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; InsertTask(...) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Nullable(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; returnValue &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;returnValue = command.ExecuteScalar&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Finally&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; ((returnValue &lt;SPAN style="COLOR: blue"&gt;Is&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;) _&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;OrElse&lt;/SPAN&gt; (returnValue.GetType &lt;SPAN style="COLOR: blue"&gt;Is&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;GetType&lt;/SPAN&gt;(System.DBNull))) &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Nullable(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Nullable(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;)(&lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(returnValue, &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;* C# version omitted since there’s no significant difference.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;As you can see from above, what gets returned from InsertTask function is actually the return value of &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;System.Data.SqlClient.SqlCommand.ExecuteScalar()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; which is &lt;I style="mso-bidi-font-style: normal"&gt;the first column of the first row in the result set, or a null reference if the result set is empty&lt;/I&gt;, not the return value of the stored procedure.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case, &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;InsertTask&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; returns null since the stored procedure does not return any result set.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;If you choose ‘No value’ option, &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;System.Data.SqlClient.SqlCommand.ExecuteNonQuery()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; is used instead.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And the return value of &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;ExecuteNonQuery()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; is &lt;I style="mso-bidi-font-style: normal"&gt;the number of rows affected&lt;/I&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Again, this is not the stored procedure return value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;So, how do you retrieve the stored procedure return value?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Although it’s not immediately obvious, there’s an easy way to access it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s look at the definition of the command object for the stored procedure.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can see it from &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasksTableAdapter.InitCommandCollection()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;&lt;SPAN style="mso-no-proof: yes"&gt; in &lt;/SPAN&gt;&lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset.Designer.vb&lt;/I&gt; / &lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset.Designer.cs&lt;/I&gt; file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[ VB]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Private&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; InitCommandCollection()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlCommand(1) {}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(0) = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlCommand&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(0).Connection = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(0).CommandText = &lt;SPAN style="COLOR: maroon"&gt;"SELECT intID, strName, intPriority, dtDueDate FROM dbo.tbTasks"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(0).CommandType = System.Data.CommandType.Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1) = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlCommand&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).Connection = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).CommandText = &lt;SPAN style="COLOR: maroon"&gt;"dbo.spInsertTask"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).CommandType = System.Data.CommandType.StoredProcedure&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).Parameters.Add(&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlParameter(&lt;SPAN style="COLOR: maroon"&gt;"@RETURN_VALUE"&lt;/SPAN&gt;, System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, 10, 0, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, System.Data.DataRowVersion.Current, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).Parameters.Add(&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlParameter(&lt;SPAN style="COLOR: maroon"&gt;"@strName"&lt;/SPAN&gt;, System.Data.SqlDbType.VarChar, 200, System.Data.ParameterDirection.Input, 0, 0, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, System.Data.DataRowVersion.Current, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).Parameters.Add(&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlParameter(&lt;SPAN style="COLOR: maroon"&gt;"@intPriority"&lt;/SPAN&gt;, System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, 10, 0, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, System.Data.DataRowVersion.Current, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;._commandCollection(1).Parameters.Add(&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Data.SqlClient.SqlParameter(&lt;SPAN style="COLOR: maroon"&gt;"@dtDueDate"&lt;/SPAN&gt;, System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, 23, 3, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, System.Data.DataRowVersion.Current, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;* C# version omitted since there’s no significant difference.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;You can see from above that parameters collection does actually include &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;@RETURN_VALUE&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; parameter.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s the first parameter in the collection.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When the stored procedure is executed, return value from the stored procedure is added to this item in the collection.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, all we need to do is to retrieve this value after executing &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;InsertTask()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; function.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To do that, I will add some code to the partial class defined in &lt;I style="mso-bidi-font-style: normal"&gt;TasksDataset.vb / TasksDataset.cs&lt;/I&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;[ VB ]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Namespace&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TasksDatasetTableAdapters&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Class&lt;/SPAN&gt; tbTasksTableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; GetReturnValue(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; commandIndex &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CommandCollection(commandIndex).Parameters(0).Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Namespace&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face=Georgia&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;[ C# ]&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; WindowsApplication1.TasksDatasetTableAdapters {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;tbTasksTableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; GetReturnValue(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; commandIndex)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.CommandCollection[commandIndex].Parameters[0].Value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face=Georgia&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;Since Dataset Designer does not generate partial class structure for TableAdapters, you will have to add above code yourself to partial class file.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The commandIndex parameter is the index of the command object in &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;_commandCollection&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt; to retrieve return value from.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can get that information by looking at &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;tbTasksTableAdapter.InitCommandCollection(). &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT face=Georgia&gt;Now, let’s modify the code that was not running to use this new function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[ VB ]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taTasks &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; TasksDatasetTableAdapters.tbTasksTableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskName &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskPriority &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; TaskDueDate &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Date&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; returnValue &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: green; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskName = &lt;SPAN style="COLOR: maroon"&gt;"Test"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskPriority = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TaskDueDate = Now()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taTasks.InsertTask(TaskName, TaskPriority, TaskDueDate)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;returnValue = taTasks.GetReturnValue(1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Consolas; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;[C#]&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;TasksDatasetTableAdapters.&lt;SPAN style="COLOR: teal"&gt;tbTasksTableAdapter&lt;/SPAN&gt; taCustomers = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; WindowsApplication1.TasksDatasetTableAdapters.&lt;SPAN style="COLOR: teal"&gt;tbTasksTableAdapter&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: teal; mso-no-proof: yes"&gt;String&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskName;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;int&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskPriority;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: teal; mso-no-proof: yes"&gt;DateTime&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; taskDueDate;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue; mso-no-proof: yes"&gt;int&lt;/SPAN&gt;&lt;SPAN style="mso-no-proof: yes"&gt; returnValue;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskName = &lt;SPAN style="COLOR: maroon"&gt;"Test"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskPriority = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taskDueDate = System.&lt;SPAN style="COLOR: teal"&gt;DateTime&lt;/SPAN&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;taCustomers.InsertTask(taskName, taskPriority, taskDueDate);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;returnValue = (int)taCustomers.GetReturnValue(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=BlogCode style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;We pass in 1 as a parameter value to &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;GetReturnValue()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; since our stored procedure is located at index 1 in &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;_commandCollection&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Above code will correctly retrieve return value from the stored procedure which is the new identity value of &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;intID&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; column.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you have more than one stored procedures that return something, you can retrieve those return values by calling &lt;/FONT&gt;&lt;SPAN class=BlogCodeChar&gt;&lt;SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;GetReturnValue()&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Georgia&gt; with correct index.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;Typed Dataset simplifies data access layer development significantly by generating necessary code for you based on the information you provide via Dataset Designer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Although generated code covers large number of scenarios, I suggest that you take a close look at generated code and find out how you can extend the functionality of default Typed Dataset.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And definitely let us know how we can improve it to make Typed Dataset more powerful and flexible.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;Also, don’t forget to let me know if you have better ways to retrieve return values from stored procedures.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;What I suggest here is just one solution and I am sure that you have other solutions that might be more elegant than this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=BlogNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Georgia&gt;&lt;STRONG&gt;&lt;EM&gt;Young Joo&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=693113" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>Q&amp;A About SQL Server Everywhere</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/04/10/572164.aspx</link><pubDate>Mon, 10 Apr 2006 05:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:572164</guid><dc:creator>SmartClientData</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/572164.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=572164</wfw:commentRss><description>&lt;P&gt;Steve posted some answers to many of the questions about SQL Server Everywhere...&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/stevelasker/"&gt;http://blogs.msdn.com/stevelasker/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=572164" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Occasionally+Connected+Data/default.aspx">Occasionally Connected Data</category><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>SQL Server Everywhere - SQL Mobile Unleashed</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/04/06/SQLEverywhere.aspx</link><pubDate>Thu, 06 Apr 2006 19:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570090</guid><dc:creator>Steve.Lasker</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/570090.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=570090</wfw:commentRss><description>&lt;FONT face=Tahoma&gt;Today Paul Flessner announced that SQL Mobile will be released as SQL Server Everywhere Edition. &amp;nbsp; &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/sql/letter.mspx"&gt;&lt;FONT face=Tahoma&gt;http://www.microsoft.com/sql/letter.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma&gt; Details are yet to be announced.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But to get a feel for what the new product will do, check out this walkthrough: &lt;/FONT&gt;&lt;A href="/smartclientdata/archive/2005/07/15/439008.aspx"&gt;&lt;FONT face=Tahoma&gt;The little database that could. &lt;/FONT&gt;&lt;/A&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;Steve&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=570090" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Occasionally+Connected+Data/default.aspx">Occasionally Connected Data</category></item><item><title>Splitting Typed DataSets from TableAdapters - Sharing Validation Code across the tiers</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/02/21/SeperatingTypedDataSetsFromTableAdapters.aspx</link><pubDate>Tue, 21 Feb 2006 21:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:536217</guid><dc:creator>Steve.Lasker</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/536217.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=536217</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma&gt;You’re building a Smart Client application.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You want this Smart Client to be smart enough to provide validation feedback to the user as they enter information.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;However, in order to make the application scale to thousands of users you can’t open connections directly to the database from the client because you’re server can’t handle that many connections.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You probably don’t want the data access information to be available on the client anyway so you turn to Web Services to help abstract the intimate knowledge about your database.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This way the client only has Web Service address and authentication information.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Since web services can be consumed by many different types of clients you don’t want to trust that all the validation rules have been enforced.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;So, what do you do?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo7; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;You could put all the validation rules in the database, but that means your database has that much more processing to do, and your Smart Client won’t be so smart.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;It will still have to make round trips to the database each time a user tabs off a control.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo7; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;You could use the XSD schema validation extensions, but they aren’t all that extensible and they don’t deal with dynamic values.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo7; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;You could write the validation code twice.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Once for the server, then again for the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;But that wouldn’t be all that maintainable.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;The likely solution is to simply write the validation logic and share it on the client and within the web service.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;But wait, that’s type sharing… that’s bad…&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Well, yes and no.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In the old days of COM/DCOM and even with Remoting you really were sharing the same actual object.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The client would instantiate a component and it would actually run on a remote server.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In addition to scalability issues, this also had a maintenance issue.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;If you ever updated the component on the server, even if it didn’t involve changing the public interface, all the clients had to be updated as well.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;To make this more complicated, since clients are running statefull operations on shared servers you usually had to completely shut down the entire system to make a simple update.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Web Services solves these problems as the object being used and what travels across the wire are really individual things.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The serialization format of a particular object has no real direct correlation to the actual object.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Yes, certain objects serialize certain types of formats, but that’s not a hard and fast rule.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;I can talk in English, French, German, Hungarian, but I’d still be saying the same thing.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Likewise, 3 different people can all say the same thing in English, and it would have the same meaning.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Once you separate the wire protocol from the functionality you can change the internal implementation all you want, and as long as you don’t change the public interface and your clients can continue to consume the service.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Now I know that many would argue that changing functionality within a service is breaking the contract.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;And to some extent you’re correct.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;If you’re exposing a public service, and don’t own all the clients then you do have an obligation to maintain consistency.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;However, if you do own the clients and the services are only consumed as part of your application then this becomes a very flexible model.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Take the following scenario:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;You roll out your application over the weekend.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Thousands of users fire up the app first thing Monday morning.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;They all get the updated version with ClickOnce deployment.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Life is good.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Later that day you notice that you forgot to put a validation rule in that all orders can’t be shipped for 7 days after the order date.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You quickly add the validation rule to enforce DueDate must be Today + 7 Days and you add a default value that DueDate is Today + 7 days, but how do you deploy this?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You could announce over the PA system that everyone must exit the sales system for 5 minutes which effectively shuts the company down and directly affects the profits of the day. That probably wouldn’t reflect well on your next review.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Or, you could update the validation logic on the server without touching the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Since the public interface didn’t change, the clients continue to function.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Since ASP.net Web Services use something called Shadow Copied assemblies, you aren’t blocked from updating an assembly in the web server.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Once the file is finished being copied, the webserver detects that one of the assemblies that’s using has changed and reloads that assembly into memory. The next request will immediately get the new functionality.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;At this point the client doesn’t have the validation logic, however, when the sales rep attempts to save an order the additional validation logic will kick in and send back the error to the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;If the developer updated the client app with the new assembly then the clients will get updated the next time they restart their app.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;You could use the ClickOnce background APIs to constantly check for updates, and that’s a good thing but you don’t want to be checking or updates ever 10 seconds.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;That sort of defeats the purpose here.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In the above example, you were able to immediately affect a change without interrupting any of the sales reps which means no downtime, and you’ve got a great review again.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;So, how do you implement all this?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The basic concepts, including some of the proxy generation issues of Web Services equally apply to custom objects, but for this article I’ll focus on how to leverage Typed DataSets to enable validation on the client but enforce it on the server.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;One of the major features of Visual Studio 2005 is the new typed data access components called TableAdapters.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;These can be used within your Data Access Layer to handle all the CRUD operations to the database.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;TableAdapters are effectively strongly typed DataAdaters.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;These bring parity with the Typed DataSet experience in Visual Studio 2002.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;One of the VS 2005 enhancements of Typed DataSets is the use of partial classes.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In 2002/03 it was very difficult to add custom logic to the Typed DataSet.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Since Visual Studio uses something called Single File Generators to generate the Typed Datasets, any code the developer added to the Typed DataSet would be lost the next time the generator ran.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Developers would sometimes inherit from the Typed DataSet but that had lots of other complications as well.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;It further complicated things as you now had two types; the one generated by Visual Studio and the one that had your validation code.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Visual Studio 2005 Typed DataSets leverage a feature known as partial classes.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Using partial classes developers can now directly enhance the functionality of the generated Typed DataSet without the possibility of being overwritten by the Single File Generator.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This means we can now easily add our validation code directly to the Typed DataSet and enforce it on the server.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;However, because Visual studio generates the Typed DataSet in the same file and project as the TableAdapters we don’t have an easy way to leverage the Typed DataSet on the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;We could add a reference to the assembly that contains the Typed DataSet and TableAdapters on the client, but now the client has the intimate knowledge of the server that we’re trying to avoid?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Great, so now what?&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Well, it turns out it’s not all that difficult to separate these.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;It’s not very discoverable, but it’s not that difficult.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;What we’re going to do is separate the Typed DataSet from the DataLayer into its own DataEntities assembly.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;We’ll create a Web Service to return the Typed DataSet and use the DataLayer assembly behind the web service.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The client application will share the reference to the DataEntities assembly on the client but it won’t have the DataLayer so we’ll keep the intimates of the database away from the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Since Web Services serializes DataSets as XML we can leverage the same type on both sides of the wire, but we’re not actually sharing the same instance so we get a lot of flexibility in how we update the application.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;The rest of this article focuses on a walkthrough for how to accomplish this.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;I’ll highlight some of the best practices for this scenario to minimize complexities for working around the default behavior of the tool.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;To get things started we’ll create a solution with the projects to represent the logical and physical tiers.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Creating the solution&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l8 level2 lfo1; tab-stops: list .25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;FONT face=Tahoma&gt;Using Visual Studio 2005 create a new solution containing 4 projects.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;I style="mso-bidi-font-style: normal"&gt;It doesn’t matter whether you’re using VB or C#.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 89.6pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=119&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Project Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 353.2pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=471&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Project Type &amp;amp; Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 89.6pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=119&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Client&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 353.2pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=471&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;A Windows Forms project&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 89.6pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=119&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;DataEntities&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 353.2pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=471&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;A Class Library that will contain our Typed DataSet with validation logic&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 3"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 89.6pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=119&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;DataLayer&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 353.2pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=471&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;A Class Library that will load and save the Typed DataSet in the DataEntities dll&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 4; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 89.6pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=119&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;BizServices&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; WIDTH: 353.2pt; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=471&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;A WebService that will simply wrap calls to the DataLayer&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l8 level2 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;Delete Class1 in the Class Libraries&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l8 level2 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;Delete the Service.asmx and Service.vb/cs file in the App_Code directory&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l8 level2 lfo1; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;You should now have a solution that looks something like the following:&lt;/FONT&gt;&lt;/P&gt;&lt;IMG src="http://windowsforms.net/Presentations/BlogImages/DataSetTableAdapterSplit/SharedDataEntitiesEmptySolution.JPG"&gt; 
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Adding a Typed DataSet/TableAdapters to the DataLayer&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l6 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;With the DataLayer selectged, open the Data Sources Window. (You can do this using the Data Menu and select Show Data Sources).&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l6 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;Add a new Data Source and choose Database&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l6 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;Add a connection to your database.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In this walkthrough we’ll use the Northwind database&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l6 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;Using the treeview, choose your tables.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;We’ll simply select the Orders table for this walkthrough.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You could use sprocs or views, but to keep this walkthrough focused, we’ll just select the orders table and press finish.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-list: l6 level1 lfo2; tab-stops: list .25in"&gt;&lt;SPAN style="mso-fareast-font-family: Tahoma; mso-bidi-font-family: Tahoma"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Tahoma&gt;5.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma&gt;You should now have a Typed DataSet and TableAdapter for the Northwind.Orders table&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;IMG src="http://windowsforms.net/Presentations/BlogImages/DataSetTableAdapterSplit/SharedDataEntities-DataSet.JPG" __designer:dtid="281474976710839"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Moving the DataSet to the DataEntities project&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;We’ll now cut and paste the Typed DataSet definition from the DataLayer to the DataEntities project to isolate the intimate knowledge of the database from the data entities.&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Show the hidden files by pressing “Show All Files” button in the top of the solution explorer&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Open the NorthwindDataSet.Designer.vb/cs file&lt;BR&gt;In this file you’ll see two major sections.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The definition of the Typed DataSet and a namespace for all the TableAdapters associated with the Typed DataSet&lt;BR&gt;It’s easiest to see the source if you collapse the regions for the Typed DataSet and the TableAdapter namespace&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;IMG src="http://windowsforms.net/Presentations/BlogImages/DataSetTableAdapterSplit/SharedDataEntities-DataSetSource.JPG"&gt; 
&lt;OL style="MARGIN-TOP: 0in" type=1 start=3&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Copy the source code from the first line through the definition of the Typed DataSet&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the DataEntities project add a new Class File and name it the same as your DataSet.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You’ll want to add the .Designer extension to maintain separation between the generated code and the validation code we’ll add later on.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In this case we’ll create &lt;B style="mso-bidi-font-weight: normal"&gt;NorthwindDataSet.Designer.vb&lt;/B&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In this file paste over the entire contents with the source you copied from the DataLayer.dll&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l7 level1 lfo3; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Back in the DataLayer project, delete the DataSet definition.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Be sure to leave the headers, Imports and if using VB, the Option Strict code &lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Fixing up the references&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;If you build the project you’ll now see a bunch of errors in the task list.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The TableAdapters reference a type that is no longer “visible”.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo8; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the DataLayer project, add a reference to the DataEntities project.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This will solve the issue of finding the types.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo8; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;You’ll now need to add a project level imports to resolve any namespace differences between the entities and DataLayer.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;VB&lt;/B&gt;: Select the DataLayer project and double click the My Project node to open the Project Properties.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Select the References tab and using the Imported Namespaces check the DataEntities namespace.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The errors should now disappear from the task list.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;FONT face=Tahoma&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;C#&lt;/B&gt;: Open the NorthwindDataSet.Designer.cs file and add an additional Using statement for the DataEntities project: &lt;BR&gt;using DataEntities;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1 start=3&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo8; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Once you build the solution you should no longer see any build errors.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;We now have data access and data entities isolated and the have the proper references. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Notice that while the DataLayer does have a reference to the DataEntites the opposite is not true. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;This means the DataEntiteis can be used without any database intimates. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;The next problem is how to get the DataEntites from the DataLayer to the client. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;This is where Web Services come in.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Using Web Services we can abstract the client form the server logic. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Note that this same process will work for the upcoming Windows Communication Framework in WinFX.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Exposing the DataEntities via Web Services&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;In order to expose the DataEntities via Web Service we’ll create some thin wrappers to delegate any calls to the DataLayer&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the BizServices web service project select add new Web Service &lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Name the Web Service &lt;B style="mso-bidi-font-weight: normal"&gt;Orders&lt;/B&gt;.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Visual Studio will create two files.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;One for IIS to expose as an address, Orders.asmx.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;And another for the code, Orders.vb/cs&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the BizServices project add references to the DataEntities and the DataLayer projects.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the Orders.vb/cs file add the following code to expose the Load and Save methods:&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; _ordersTableAdapter &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; DataLayer.NorthwindDataSetTableAdapters.OrdersTableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_ordersTableAdapter = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; DataLayer.NorthwindDataSetTableAdapters.OrdersTableAdapter()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;WebMethod()&amp;gt; _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; GetOrders() &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; DataEntities.NorthwindDataSet.OrdersDataTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; _ordersTableAdapter.GetData()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;WebMethod()&amp;gt; _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; SaveOrders(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; orders &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; DataEntities.NorthwindDataSet.OrdersDataTable) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; DataEntities.NorthwindDataSet.OrdersDataTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; orders.HasErrors &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; orders&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_ordersTableAdapter.Update(orders)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; orders&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1 start=5&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l4 level1 lfo4; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;We now have the ability to return and save Orders to the database.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The sample above does do some validation testing within the web service which you’d likely want to place in a separate assembly. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;You could place it in the DataLayer as well&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The point is you want to minimize the actual code in the Web Services project so you’ll have more flexibility for where to use this code. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;For instance, when WCF ships you’ll likely want to leverage some of the new transports. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;By keeping the code in the web service to an absolution minimum you’ll ease your migration process.. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR&gt;Another thing worth notice is while this sample focuses on a simple 1:1 mapping of the database to the returned DataSet, that isn’t the limitation of DataSets.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The TableAdapter wizards are optimized for relatively simple mappings, but using ADO.net commands, Stored Procedures and/or Views, you can do quite a bit of additional logic to differentiate the schemas of your DataSet from the underlying database.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Using the merge capabilities of DataSet, you can have a single DataSet or even a single DataTable represent data from two or more database systems.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;But, that’s a discussion for another day.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Consuming the DataEntities in your WinForms client&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;FONT face=Tahoma&gt;We’ll now add the ability to load and save a form full of customers. In the client project we’ll add a Web reference to our BizServices to get the load and save functionality and we’ll add an additional reference to the DataEntities dll.to leverage common validation logic on the client and the server. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Note that we won’t have any reference to the DataLayer dll so the client will be clean of data access knowledge.&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Using Solution Explorer select Add Web Reference in the Client project.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You could use the Data Sources Window, but we’ll want to rename the service and this feature isn’t available in the Data Sources Window wizard.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the Web Reference wizard browse Web services in this solution.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You should now see your Orders service.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Since LocalHost is fairly meaningless, select the Orders Service and rename it OrdersService.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Press finish to continue&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo5; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;If you notice the Data Sources Window you’ll see the dataset returned by the web service is now available.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;What’s important to note is while this dataset is the same “shape” as the data set returned by the Web Service, it’s not the same Type as the DataSet in the DataEntities project.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The Web Reference Dialog created a proxy type for the dataset.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;If you show the hidden files you can navigate through the OrdersService, Reference.map to find the refernce.vb file.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This contains the code necessary to call the OrdersService, but it also contains a type definition for the NorthwindDataSet.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;While it is declared as Partial, we’re not going to leverage this feature.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR&gt;&lt;IMG src="http://windowsforms.net/Presentations/BlogImages/DataSetTableAdapterSplit/SharedDataEntities-WebServiceProxy.JPG"&gt; &lt;BR&gt;Due to time constraints in the Visual Studio 2005 schedule we were unable to complete a feature we refer to as Proxy Type Sharing.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;If you consume multiple web services from the same project that return the same type, Visual Studio will create multiple proxy types on the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This means you could actually wind up with several TypedDataSets on the client that all share the same shape.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;However, even if we fixed Proxy Type Sharing, we still wouldn’t have exactly what we need in this scenario. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;In this case, we already have the type on the client, so we don’t need a proxy. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;In a few steps, we’ll see how we consolidate these.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Merging the proxy and original types&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;FONT face=Tahoma&gt;Although we’ll use the Web Service to get and save orders, we’re not going to use this TypedDataSet to represent our data within our client app.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Instead we’re going to use the DataEntities dataset&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;With the Client project active, use the Data Sources Window to add an Object Data Source.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Add a reference to the DataEntities project and select the NorthwindDataSet as your Object DataSource.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR&gt;Visual studio differentiates Object Data Sources from Database DataSources by providing a different design experience.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When the developer chooses Database datasources, Visual Studio creates Typed DataSets and TableAdapters.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When you drag &amp;amp; drop Database DataSources from the Data Sources Window Visual Studio will add additional load and save code to your form.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;For Object Data Sources, Visual Studio doesn’t make any assumptions about how you load and save your objects.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Typed DataSets are simply very specialized data object containers that have all the necessary plumbing for serializing and databinding.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;With Form1 open, select the DataEntities.Northwind.Orders object in the Data Sources Window and drag it to the form.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Be sure you’re getting the right DataSet, it can be confusing as they’re both named similarly.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;
&lt;OL style="MARGIN-TOP: 0in" type=a&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level2 lfo9; tab-stops: list 1.0in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT face=Tahoma&gt;You can remove the Web Service DataSet proxy from the Data Sources Window with a little work around. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If you show hidden files in the Client project and navigate through OrdersService -&amp;gt; Reference.map you’ll see a NorthwindDataSet.datasource file. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;This file is what Visual Studio uses to show object in the Data Sources Window. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If you delete this file the entry will be removed from the Data Sources Window but the Web Service will still exist. If you ever update the web reference the .datasource file will be recreated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Double click the form to get the form.load event and add the following code to merge the DataSet returned by the web service with the DataEntities DataSet. &lt;/FONT&gt;
&lt;OL style="MARGIN-TOP: 0in" type=a&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level2 lfo9; tab-stops: list 1.0in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT face=Tahoma&gt;We could do another work around and change the code generated by the web service proxy generator, however this is much more complicated to maintain. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Since DataSets and DataTables support merge capabilities, we can avoid changing the generated code. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;For plain old objects, (POOs) that don’t support merge capabilities, you’ll likely want to edit the proxy generated code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Form1_Load(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Object, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.EventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;MyBase&lt;/SPAN&gt;.Load&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.NorthwindDataSet.Orders.Merge(&lt;SPAN style="COLOR: blue"&gt;My&lt;/SPAN&gt;.WebServices.Orders.GetOrders())&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT face=Tahoma&gt;Notice that DataTables now support merging directly.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In 1.x, you had to merge the entire DataSet.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Also note that we were able to return an individual Typed DataTable rather then the entire DataSet.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;This only works for Typed DataTables,&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You can’t return a single UnTyped DataTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1 start=4&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Activate the form designer again and enable the Save button that was created in the BindingNavigatgor&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Double click the Save button and add the following code to commit any changes made by the user and send the changes to the server.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; OrdersBindingNavigatorSaveItem_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Object, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.EventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; OrdersBindingNavigatorSaveItem.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Validate()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.OrdersBindingSource.EndEdit()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; orderServiceOrderTable &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; Client.OrdersService.NorthwindDataSet.OrdersDataTable()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;orderServiceOrderTable.Merge(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.NorthwindDataSet.Orders.GetChanges())&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;orderServiceOrderTable = &lt;SPAN style="COLOR: blue"&gt;My&lt;/SPAN&gt;.WebServices.Orders.SaveOrders(orderServiceOrderTable)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; orderServiceOrderTable.HasErrors &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MessageBox.Show(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;"Errors on attempt to save"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.NorthwindDataSet.Orders.Merge(orderServiceOrderTable)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1 start=6&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Hit F5 to run you’re app&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;If you look in the bin directory of the Client app you’ll notice we only have the DataEntities.dll and Client.exe files.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The DataLayer which contains all the intimate knowledge of the Databas are left out of the picture.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l5 level1 lfo9; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Using ClickOnce, publish the Client project and install it on your machine.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Be sure to use the default behavior so you get the Start menu item&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Adding Validation Code&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;FONT face=Tahoma&gt;Now that we’ve got the client project setup and deployed, let’s add some validation logic.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;In order to demonstrate the lack of tight coupling, we’ll add the validation logic to the DataEntities project, but we won’t actually deploy this to the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;So, when testing this, be sure not to republish the client.&lt;/FONT&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo6; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the DataEntities project add a new class file.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Name it NorthwindDataSet.vb/cs.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Note that we’re using the same standard as forms and the DataSet designer to isolate designer generated code from your code.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo6; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;In the file add the following code:&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; OrdersDataTable_ColumnChanged(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Data.DataColumnChangeEventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ColumnChanged&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' We use the Changed event as we try to avoid deleting information a user enters&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Rather we show them what they typed, but provide information indicating the specific error&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' This helps users understand if they mistyped, or the information is just not permitted&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Use strongly typed names of the columns to benefit from compile time verification &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' If the user changed the OrderDate or ShippedDate columns, verify the dates&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; e.Column.ColumnName = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.OrderDateColumn.ColumnName &lt;SPAN style="COLOR: blue"&gt;Or&lt;/SPAN&gt; _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;e.Column.ColumnName = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ShippedDateColumn.ColumnName &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ValidateDates(e.Row)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; ValidateDates(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; row &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; OrdersRow)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Check for specific column errors and set or clear the errors&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Using this model, DataSets will surface the errors using the IDataError interface&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' DataBinding in the DataGridView and ErrorProvider will pick up these errors&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' and surface them to the user&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' You may want to use strongly typed Resources for the error strings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; row.OrderDate &amp;gt; row.ShippedDate &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;row.SetColumnError(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.OrderDateColumn, &lt;SPAN style="COLOR: maroon"&gt;"Can't ship before it's been ordered"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;row.SetColumnError(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ShippedDateColumn, &lt;SPAN style="COLOR: maroon"&gt;"Can't ship before it's been ordered"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;row.SetColumnError(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.OrderDateColumn, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;row.SetColumnError(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ShippedDateColumn, &lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in" type=1 start=3&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo6; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Rebuild the entire solution to make sure the updated DataEntites dll gets pushed up to the Web Service project.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo6; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;With the app still running, change the OrderDate to be after the ShippedDate.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Note that if you closed the app from above, simply start it again from the start menu so you get the version that doesn’t have the updated DataEnties on the client.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;Notice that you don’t see any errors in the DataGridView. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo6; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Press the save button.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;You may notice a slight delay as the Web Service re-computes the updated assembly, but when it returns you should now see ErrorProviders indicating that the ShipDate can’t be before the OrderDate. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Updating the client&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;To update the client, simply republish the Client project using the ClickOnce deployment wizard and restart your client app. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Wrapping Up&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;With the above scenarios you were able to make changes to the DataEntities without breaking the client applications. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;You’re users maintained their productivity, yet you were able to quickly add new validation rules. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;The clients could then be updated to complete the update, but you didn’t break you’re users workflow in the process. &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;With the basic tooling support in Visual Studio and these tricks you can achieve a truly factored ‘N scale application that leverages code where you want, scales to thousands of users, can be updated mid day without kicking your users off the system and delivers on the promise of Smart Clients for productive users.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;Post Whidbey, we are working to enable this scenario without all the work arounds noted above, but for now…&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;&lt;/FONT&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT face=Tahoma&gt;Steve&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=536217" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Blogicles/default.aspx">Blogicles</category><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>Relation Dialog: Relation Only, or with Foreign Key Constraint?</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/02/13/530786.aspx</link><pubDate>Mon, 13 Feb 2006 11:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:530786</guid><dc:creator>SmartClientData</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/530786.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=530786</wfw:commentRss><description>&lt;P&gt;Using the Relation Dialog, you are asked to choose Relation Only, Foreign Key Constraint Only, or Both.&amp;nbsp; Which is the right choice?&amp;nbsp; &lt;/P&gt;
&lt;P&gt;“Relation Only” makes available the tables related to the table that you are working with.&amp;nbsp; This means that if you are working with, for example, both a Customers table with CustomerID as primary key and an Orders table with CustomerID as foreign key, you can establish a relationship based on their common key (CustomerID) by inserting a relation.&amp;nbsp; Without the relation, the dataset is not able to keep track that CustomerID field in one table is related to the CustomerID field in another table.&lt;/P&gt;
&lt;P&gt;Foreign key constraint enables enforcing constraints for what-is-called referential integrity, controlling changes to primary key data.&amp;nbsp; For example, if you tried to change a CustomerID value in the Customers table, the corresponding CustomerID value in the Orders table may no longer be valid.&amp;nbsp; A foreign key constraint is able to help prevent this situation.&amp;nbsp; With the foreign key constraint enabled, a failure will occur if changes are made to primary key values that have corresponding foreign key values.&lt;/P&gt;
&lt;P&gt;A foreign key constraint only with no relation is implemented for efficiency, since it will contain fewer methods than one with relation.&amp;nbsp; However, related tables will not be accessible.&lt;/P&gt;
&lt;P&gt;For further information, check out my sources: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconIntroductionToDatasetRelations.asp"&gt;Introduction to DataRelation Objects&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_04_8ypg.asp"&gt;Foreign Key Constraints&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yun Zhou&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=530786" width="1" height="1"&gt;</description></item><item><title>VSLive San Francisco Presentations</title><link>http://blogs.msdn.com/smartclientdata/archive/2006/02/01/522549.aspx</link><pubDate>Thu, 02 Feb 2006 00:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:522549</guid><dc:creator>SmartClientData</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/522549.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=522549</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;At VSLive&amp;nbsp;I presented two sessions.&amp;nbsp; One for &lt;B style="mso-bidi-font-weight: normal"&gt;Occasionally Connected Smart Clients&lt;/B&gt; and another on &lt;B style="mso-bidi-font-weight: normal"&gt;Advancements in Data Access.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;The &lt;B style="mso-bidi-font-weight: normal"&gt;Occasionally Connected Smart Client&lt;/B&gt; session focused on what we’re working on post VS 2005. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Some of which should be in Orcas, some of which will follow afterwards. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Mostly the session was about providing an overview of the evolving application model to leverage SOA based architecture, but not cripple end users at the same time. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;In the session I talked about some of the early thinking on some of the Occasionally Connected Systems compnents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Tahoma&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;The &lt;B style="mso-bidi-font-weight: normal"&gt;Advancements in Data Access&lt;/B&gt; session focused on a few questions that come up a lot around the VS Data features. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;In particular I covered:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;How to separate your Typed DataSets from your TableAdapters&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Increasing the performance of Typed DataSet Serialization by skipping schema with DataSet.SchemaSerializationMode = ExcludeSchema&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt; 
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT face=Tahoma&gt;Implementing a common interface for TableAdapters, ITableAdapter&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt; 
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;FONT face=Tahoma&gt;Doing a hierarchical update within a transactions &lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;A href="/smartclientdata/attachment/522549.ashx"&gt;Slides &amp;amp; Demos&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.ftponline.com/channels/net/reports/vslivesf/2006/"&gt;Recording of the VSLive Session&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Enjoy&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT face=Tahoma&gt;Steve&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=522549" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/smartclientdata/attachment/522549.ashx" length="3315678" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Presentations/default.aspx">Presentations</category><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Post+Whidbey+Thinking/default.aspx">Post Whidbey Thinking</category><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Occasionally+Connected+Data/default.aspx">Occasionally Connected Data</category></item><item><title>Embedding SQL Server Express into Custom Applications</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/11/23/496314.aspx</link><pubDate>Wed, 23 Nov 2005 20:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:496314</guid><dc:creator>SmartClientData</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/496314.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=496314</wfw:commentRss><description>&lt;P&gt;Rob Walters, from the SQL Team, and I worked on an article for working with SQL Express in Windows Forms applications.&amp;nbsp; There are a couple of quirks when it comes to Click Once that have been included in this MSDN article.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/EmSQLExCustApp.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/EmSQLExCustApp.asp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=496314" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Occasionally+Connected+Data/default.aspx">Occasionally Connected Data</category><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>Building SQL manually considered harmful</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/11/22/495895.aspx</link><pubDate>Tue, 22 Nov 2005 22:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:495895</guid><dc:creator>SmartClientData</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/495895.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=495895</wfw:commentRss><description>I just got done fixing a painful bug. The long and short of it is that I had code like this (simplified a lot for brevity):&lt;br/&gt;
&lt;xmp&gt;    Public Sub StoreSyncDate()
        Dim sql As String = "insert into SyncTimes (ObjectID, SyncDate) values ({0}, '{1}')"
        sql = String.Format(sql, Me.ID, DateTime.Now)
        Me.Executequery(sql)
    End Sub&lt;/xmp&gt;
On my machine, sql gets passed as a string like &lt;i&gt;"insert into SyncTimes (ObjectID, SyncDate) values (42, '11/22/2005 11:34:45 AM')"&lt;/i&gt;. Life is good (ignore the SQL injection security problem for the moment).&lt;br/&gt;
&lt;br/&gt;
Then a co-worker in Ireland emails me to ask why my application has broken. Things were working fine earlier in the month, but now he's getting an unhandled exception. What's going on here? Head over to your Regional settings in the Control Panel and change your region to English (Ireland) for some local flavor: &lt;i&gt;"insert into SyncTimes (ObjectID, SyncDate) values (42, &lt;b&gt;'22/11/2005 11:34:15'&lt;/b&gt;)"&lt;/i&gt;. There's no month 22, SQL complains, life is not good. The even trickier part is before the 13th of the month, dd/mm/yyyy strings turn in to valid mm/dd/yyyy strings. This is probably worse since it's subtle data corruption rather than an obvious error.&lt;br/&gt;
&lt;br/&gt;
So the moral of the story is, be smarter than me. You never know what will go wrong when you're not using parameterized queries.&lt;br/&gt;
&lt;br/&gt;
Ryan Cavanaugh&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=495895" width="1" height="1"&gt;</description></item><item><title>How do I get to the generated code?</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/11/19/494737.aspx</link><pubDate>Sat, 19 Nov 2005 05:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:494737</guid><dc:creator>SmartClientData</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/494737.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=494737</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;In order to get to the code that is auto-generated by Visual Studio, follow these steps:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1.&amp;nbsp;In the menu, select View -&amp;gt; Solution Explorer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2.&amp;nbsp;In Solution Explorer, click the “Show all Files” icon at the top&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3.&amp;nbsp;Expand the file (e.g. Dataset1.xsd) that you want the generated code for&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4.&amp;nbsp;Double click on the corresponding Designer file (e.g. Dataset1.Designer.vb) to open up the generated code&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;From there, you can read and edit the underlying code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;~ Yun Zhou&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=494737" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>Data Sources window is inactive in Design View</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/11/18/494639.aspx</link><pubDate>Sat, 19 Nov 2005 00:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:494639</guid><dc:creator>SmartClientData</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/494639.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=494639</wfw:commentRss><description>&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;On certain machines, after installing Visual Studio 2005, the contents of the Data Sources window disappears when a design surface that allows drag and drop from the Data Sources window is active. For example, the Windows Forms designer, User Control Designer, etc…&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The cause of this issue is how VS processes the list of associated controls for each data type in the Data Sources window.&amp;nbsp;When users customize the controls in the Data Sources window the settings are saved in the &lt;STRONG&gt;WinFormControls.xml &lt;/STRONG&gt;file in the users application data folder. The version numbers in this file have been changed between beta releases and the RTM release and this mismatch of version numbers is the cause of the disabled Data Sources window. Basically this means if you customized the list in a pre-release version of Visual Studio and then install the released version on the same machine you might run into this problem as the installer for Visual Studio does not overwrite or remove this file during setup.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;To fix this you have the following 2 options:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Option 1 fixes the problem but no customization is saved and the Data Sources window returns to its original state just like you installed a fresh product:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;1)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Close Visual Studio&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;2)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Delete &amp;lt;DriveLetter&amp;gt;:\Documents and Settings\&amp;lt;UserName&amp;gt;\Application Data\Microsoft\Visual Studio\8.0\DataBindingSetting\WinFormControls.xml&lt;BR&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#ff0000&gt;Note: &lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color=#ff0000&gt;For Express versions use: &lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;lt;DriveLetter&amp;gt;:\Documents and Settings\&amp;lt;UserName&amp;gt;\Application Data\Microsoft\VBExpress\8.0\DataBindingSetting&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;FONT color=#ff0000&gt;&lt;STRONG&gt;&lt;EM&gt;Or, you can simply search for WinFormControls.xml under &lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&amp;lt;DriveLetter&amp;gt;:\Documents and Settings\&amp;lt;UserName&amp;gt;\Application Data\Microsoft\&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Option 2 fixes the problem and attempts to preserve any customizations you applied to the Data Sources window previously:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;1)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Close Visual Studio&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;2)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Open the xml file (&amp;lt;DriveLetter&amp;gt;:\Documents and Settings\&amp;lt;UserName&amp;gt;\Application Data\Microsoft\Visual Studio\8.0\DataBindingSetting\WinFormControls.xml)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial color=#ff0000 size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;STRONG&gt;&lt;EM&gt;Note: see above for other SKU's&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;3)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Check if the version numbers of System.Windows.Forms are 2.0.0.0 (this is the RTM version)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;4)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;If the version number is not 2.0.0.0 replace the version number with 2.0.0.0&lt;/SPAN&gt;&lt;/FONT&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;5)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT size=1&gt;&lt;SPAN style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;If the version number is 2.0.0.0 delete the file (unfortunately prior settings will be lost, sorry…)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;We apologize for any inconvenience this may be causing developers who have installed previous Betas or CTP versions of Visual Studio to help provide early feedback of the product.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=494639" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/smartclientdata/archive/tags/Whidbey+Q+_2600_+A/default.aspx">Whidbey Q &amp; A</category></item><item><title>Installing Northwind on SqlExpress</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/11/02/488258.aspx</link><pubDate>Wed, 02 Nov 2005 19:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:488258</guid><dc:creator>SmartClientData</dc:creator><slash:comments>23</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/488258.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=488258</wfw:commentRss><description>&lt;P&gt;When performing a default&amp;nbsp;install of&amp;nbsp;Visual Studio 2005 an instance of Sql Server Express edition&amp;nbsp;is installed. Unfortunately there are no sample databases included with Sql Express. (&lt;A href="http://lab.msdn.microsoft.com/express/sql/"&gt;http://lab.msdn.microsoft.com/express/sql/&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;I've had more than a few people ask how to get the Northwind sample database loaded into Sql Express so here are some step-by-step directions for getting Northwind up and running so you can start trying out&amp;nbsp;all the great new data&amp;nbsp;features in VS.&lt;/P&gt;
&lt;P&gt;1) Navigate to the following URL and lick the Download button - &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&amp;amp;displaylang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2) Complete the download and install process. This places the necessary files for Northwind (and Pubs) into the "c:\Sql Server 2000 Sample Databases" folder.&lt;/P&gt;
&lt;P&gt;3) Open a command window. (Go to Start, Run, type Command and click OK)&lt;/P&gt;
&lt;P&gt;4) Change the directory to the sample databases (type:&amp;nbsp; cd c:\SQL Server Sample Databases)&lt;/P&gt;
&lt;P&gt;5) Type or paste the following into the command window replacing computerName with the actual name of your computer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;osql -E -S computerName/SqlExpress -i instnwnd.sql&lt;/P&gt;
&lt;P&gt;6) now go to VS and create a data connection using the computerName\sqlexpress as the Server name in the Add Connection dialog. The Northwind database should now be available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Steve Stein&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=488258" width="1" height="1"&gt;</description></item><item><title>Returning the identity column value from a TableAdapter DBDirect method</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/10/31/ReturnIdentityValueQuery.aspx</link><pubDate>Mon, 31 Oct 2005 23:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:487448</guid><dc:creator>SmartClientData</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/487448.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=487448</wfw:commentRss><description>A common scenario when using tables with an auto-increment primary key is to get the value of the identity column for the row you just inserted. Sometimes you can't, or don't want to, use DataSets, which is why we created the DBDirect methods on the TableAdapter. However, the default INSERT function doesn't return the primary key value. How can we get this in one step?&lt;br/&gt;
&lt;br/&gt;
I've created a Visual Basic Console Application and added a DataSource with the Orders table from the SQL Northwind database. The first thing I'm going to do is make a custom INSERT query on the OrdersTableAdapter. Go to the Northwind.xsd file, right-click on OrdersTableAdapter, and choose Add -&gt; "Query...". The TableAdapter Query Wizard will appear. Choose "Use SQL Statements" since we won't be using stored procedures in this example. Select "INSERT" for the query type. Now the default SQL statement appears:
&lt;blockquote&gt;&lt;xmp&gt;INSERT INTO [dbo].[Orders] ([CustomerID], [EmployeeID], [OrderDate], [RequiredDate],
[ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode],
[ShipCountry]) VALUES (@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight,
@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry);
SELECT OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName,
ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM Orders WHERE
(OrderID = SCOPE_IDENTITY())&lt;/xmp&gt;&lt;/blockquote&gt;

Let's delete the bottom half since we won't be using this query to refresh a DataSet:
&lt;blockquote&gt;&lt;xmp&gt;INSERT INTO [dbo].[Orders] ([CustomerID], [EmployeeID], [OrderDate], [RequiredDate],
[ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode],
[ShipCountry]) VALUES (@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight,
@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry);&lt;/xmp&gt;&lt;/blockquote&gt;
That's a bit more manageable. Now comes the magic part. We'll add a statement to return the @@IDENTITY value:
&lt;blockquote&gt;&lt;xmp&gt;INSERT INTO [dbo].[Orders] ([CustomerID], [EmployeeID], [OrderDate], [RequiredDate],
[ShippedDate], [ShipVia], [Freight], [ShipName], [ShipAddress], [ShipCity], [ShipRegion], [ShipPostalCode],
[ShipCountry]) VALUES (@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShippedDate, @ShipVia, @Freight,
@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode, @ShipCountry);
SELECT @@IDENTITY;&lt;/xmp&gt;&lt;/blockquote&gt;
I named the new function "InsertAndReturnIdentity". There's one last important piece: select the new query in the DataSet Designer and change the &lt;b&gt;ExecuteMode&lt;/b&gt; property from NonQuery to Scalar. We'll explain the difference between the two in a later entry.&lt;br/&gt;
&lt;br/&gt;
Now we're ready to code. We'll create a new TableAdapter and insert a row with a bunch of dummy values:&lt;blockquote&gt;&lt;xmp&gt;
    Sub Main()
        Dim ordersTA As New NorthwindDataSetTableAdapters.OrdersTableAdapter
        Dim id As Integer
        id = ordersTA.InsertAndReturnIdentity("ALFKI", Nothing, Nothing, _
		Nothing, Nothing, Nothing, Nothing, "", "", "", "", "", "")
        Console.WriteLine("The new OrderID is {0}", id)
    End Sub
&lt;/xmp&gt;
&lt;/blockquote&gt;
&lt;br/&gt;
The output is:&lt;br/&gt;
&lt;xmp&gt;The new OrderID is 11083&lt;/xmp&gt;&lt;br/&gt;
And that's all there is to it!&lt;br/&gt;
- Ryan Cavanaugh&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=487448" width="1" height="1"&gt;</description></item><item><title>Why is my column named _Region in the Typed DataSet?</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/10/14/481238.aspx</link><pubDate>Fri, 14 Oct 2005 23:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:481238</guid><dc:creator>SmartClientData</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/481238.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=481238</wfw:commentRss><description>&lt;FONT face=Verdana&gt;One quirk you'll find when making a typed DataSet with a column or table named "Region" is that the generated code produces a property called "_Region".&lt;BR&gt;&lt;BR&gt;What's up with that? If you read &lt;a href="http://blogs.msdn.com/oldnewthing/"&gt;Raymond Chen's blog&lt;/A&gt;, you already have a pretty good guess: Backward compatability.&lt;BR&gt;&lt;BR&gt;In previous versions of Visual Studio, we did the same thing. Why did we do it back then? When we generated a typed DataSet, we ask the Code DOM provider (a generic way of producing semantically equivalent code in multiple languages) if a property name is a valid identifier. This is important so that when you have a column named "Class", we generate "_Class" and the DataSet still compiles. Before Visual Studio 2005, Code DOM provider told us that "Region" was not a valid identifier, so we helpfully fixed up the to be "_Region". The catch is, "Region" &lt;i&gt;is&lt;/I&gt; a valid identifier in VB. In the latest version, the Code DOM was fixed to answer the question correctly.&lt;BR&gt;&lt;BR&gt;All is good so far - a bug got fixed in the product, so everyone should be happier, right?. Until you migrate your VS 7.1 DataSet with a column called "Region" to VS 8.0 and regenerate the designer code. The result is that all of your code which referenced _Region is no longer valid. Life isn't so good now. In the end we decided that the best thing to do was special-case the name in the generator so that compatability would be maintained. Since there's no difference between "old" DataSets and "new" ones, people writing new code still get to see this (very minor and rare) oddity. Such is the price we pay for compatability&lt;BR&gt;&lt;BR&gt;&lt;B&gt;Bonus trivia&lt;/B&gt;: We detect this case for another name: "ExternalSource" also gets a free underscore in the DataSet generator.&lt;BR&gt;&lt;BR&gt;- Ryan Cavanaugh &lt;/FONT&gt;&lt;/A&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=481238" width="1" height="1"&gt;</description></item><item><title>Case sensitive or not sensitive</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/10/07/478087.aspx</link><pubDate>Fri, 07 Oct 2005 05:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:478087</guid><dc:creator>SmartClientData</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/478087.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=478087</wfw:commentRss><description>&lt;P&gt;In a Dataset, case sensitive seems only apply to the data not to the schema &lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Within a dataset, table and column names are by default case-insensitive — that is, a table in a dataset called "Customers" can also be referred to as "customers." This matches the naming conventions in many databases, including the default behavior of SQL Server, where the names of data elements cannot be distinguished only by case.&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000000 size=2&gt;Look at carefully for the following code: &lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#008000 size=2&gt;VB ------------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ds As DataSet =&amp;nbsp; New DataSet() &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim t1 As DataTable =&amp;nbsp; New DataTable("ABC") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim t2 As DataTable =&amp;nbsp; New DataTable("abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds.Tables.Add(t1)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim b1 As Boolean =&amp;nbsp; ds.Tables.Contains("Abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' return true &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim t3 As DataTable =&amp;nbsp; ds.Tables("Abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' return ABC &lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ds.Tables.Add(t2)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim b2 As Boolean =&amp;nbsp; ds.Tables.Contains("ABC") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim b3 As Boolean =&amp;nbsp; ds.Tables.Contains("abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim b4 As Boolean =&amp;nbsp; ds.Tables.Contains("Abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim t4 As DataTable =&amp;nbsp; ds.Tables("ABC") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim t5 As DataTable =&amp;nbsp; ds.Tables("abc") &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' this would throw dim t6 as DataTable = ds.Tables["Abc"]&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;&lt;FONT color=#008000 size=2&gt;
&lt;P&gt;C#--------------------------------&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;FONT color=#008080 size=2&gt;DataSet&lt;/FONT&gt;&lt;FONT size=2&gt; ds = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataSet&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt; t1 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"ABC"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt; t2 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"abc"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;ds.Tables.Add(t1);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; b1 = ds.Tables.Contains(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Abc"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// return true, case&amp;nbsp;&amp;nbsp;insensitive &lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt; t3 = ds.Tables[&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Abc"&lt;/FONT&gt;&lt;FONT size=2&gt;]; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// return ABC &lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;ds.Tables.Add(t2);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; b2 = ds.Tables.Contains(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"ABC"&lt;/FONT&gt;&lt;FONT size=2&gt;); // true &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; b3 = ds.Tables.Contains(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"abc"&lt;/FONT&gt;&lt;FONT size=2&gt;); // true &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; b4 = ds.Tables.Contains(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"Abc"&lt;/FONT&gt;&lt;FONT size=2&gt;); // false now -- Case sensitive now &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt; t4 = ds.Tables[&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"ABC"&lt;/FONT&gt;&lt;FONT size=2&gt;]; // ok &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DataTable&lt;/FONT&gt;&lt;FONT size=2&gt; t5 = ds.Tables[&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"abc"&lt;/FONT&gt;&lt;FONT size=2&gt;]; // ok &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// this would throw DataTable t6 = ds.Tables["Abc"]&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;Karol and I have encountered this in our dataset designer and this is by design from DataSet team. &amp;nbsp;So you need to be careful not be fooled. We alway treat the table name in a case sensitive way with our own version of Contains&amp;nbsp;functions like:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public static bool ContainsTable( DataTableCollection tables, string name ) {&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( tables.Contains(name) ) {&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataTable table = tables[name];&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( StringUtil.EqualValue(table.TableName, name) ) {&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return true;&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return false;&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;This case sensitive issue applies to DataColumn, DataRelation and Constrains too. &lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;JohnChen (Zhiyong) &lt;/P&gt;
&lt;P lang=ZH-TW style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Smart Client Data Team &lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=478087" width="1" height="1"&gt;</description></item><item><title>Performance tip for databound UI</title><link>http://blogs.msdn.com/smartclientdata/archive/2005/09/19/471518.aspx</link><pubDate>Tue, 20 Sep 2005 01:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:471518</guid><dc:creator>SmartClientData</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/smartclientdata/comments/471518.aspx</comments><wfw:commentRss>http://blogs.msdn.com/smartclientdata/commentrss.aspx?PostID=471518</wfw:commentRss><description>&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;When loading large amounts of data into a dataset table with databound UI, things can get pretty slow. One reason is&amp;nbsp;that each time a row is added to&amp;nbsp;the&amp;nbsp;table, the databinding components will perform some work and tell the databound controls that a new record was added. To improve performance, you can&amp;nbsp;suspend the binding events while the data is being loaded. The BindingSource component has a RaiseListChangedEvents property for that purpose. Here's an example how to use it:&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddressBindingSource.RaiseListChangedEvents = False&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddressTableAdapter.Fill(AdventureWorksDataSet.Address)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddressBindingSource.RaiseListChangedEvents = True&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AddressBindingSource.ResetBindings(False);&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;Another&amp;nbsp;option is to&amp;nbsp;disconnect the BindingSource component while the Fill is being executed by setting its DataSource property to Nothing and reconnect it after Fill has completed.&lt;BR&gt;&lt;BR&gt;HTH&lt;BR&gt;&lt;BR&gt;Antoine&lt;BR&gt;Visual Studio Data Design-time&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=471518" width="1" height="1"&gt;</description></item></channel></rss>