<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>two geeks...</title>
	<atom:link href="http://twogeeks.mindchronicles.com/Index.php?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://twogeeks.mindchronicles.com</link>
	<description>blogging about technology together</description>
	<lastBuildDate>Tue, 11 May 2010 13:41:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Click of Death Anthem</title>
		<link>http://twogeeks.mindchronicles.com/?p=47</link>
		<comments>http://twogeeks.mindchronicles.com/?p=47#comments</comments>
		<pubDate>Tue, 11 May 2010 13:41:42 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=47</guid>
		<description><![CDATA[Now this is what I call creative viral marketing. From SanDisk&#8217;s YouTube page, they say &#8220;You know that terrible clicking sound you hear in an old computer when its on the verge of death? At SanDisk, were bringing life to old products and, in this case, bringing life to the click of death. Check out [...]]]></description>
			<content:encoded><![CDATA[<p>Now this is what I call creative viral marketing. From SanDisk&#8217;s YouTube page, they say &#8220;You know that terrible clicking sound you hear in an old computer when its on the verge of death? At SanDisk, were bringing life to old products and, in this case, bringing life to the click of death. Check out how a SanDisk SSD can revive your PC: http://bit.ly/d9bkuK &#8221;</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Qqv1GS7ShH8&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/Qqv1GS7ShH8&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=47" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=47</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: Updating One Table with the Values of Another Table</title>
		<link>http://twogeeks.mindchronicles.com/?p=41</link>
		<comments>http://twogeeks.mindchronicles.com/?p=41#comments</comments>
		<pubDate>Thu, 04 Mar 2010 07:23:46 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=41</guid>
		<description><![CDATA[For one reason or another, I often have to update rows in one table with the values in another table, and every time I do, I end up Googling for the answer.
I don’t claim to have come up with this little code snippet* but I’m putting it up here so I don’t have to waste [...]]]></description>
			<content:encoded><![CDATA[<p>For one reason or another, I often have to update rows in one table with the values in another table, and every time I do, I end up Googling for the answer.</p>
<p>I don’t claim to have come up with this little code snippet* but I’m putting it up here so I don’t have to waste time looking for it again. And if it helps you, feel free to snag and use.<br />
<code><br />
   UPDATE T<br />
   SET<br />
      T.fieldOne= S.oneValue,<br />
      T.fieldTwo= S.twoValue<br />
   FROM [TargetTable] T<br />
      JOIN [SourceTable] S ON T.id = S.id<br />
</code><br />
<em>* I believe I first saw it on SQLTeam.com but I can’t find the original article now.</em></p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=41" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Paths, LinkButtons and A Hrefs</title>
		<link>http://twogeeks.mindchronicles.com/?p=31</link>
		<comments>http://twogeeks.mindchronicles.com/?p=31#comments</comments>
		<pubDate>Thu, 09 Oct 2008 09:27:12 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[asp .net]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=31</guid>
		<description><![CDATA[When you should consider replacing LinkButtons with good ol' <a href> tags, and how you can use 'em with a little bit of .NET capability.</a>]]></description>
			<content:encoded><![CDATA[<p>One of the drawbacks of .NET, I feel, is that in making things easier for the developer, it also makes it very easy to &#8220;bloat&#8221; our pages. If you&#8217;re a drag-and-drop developer (which is part of the appeal of .NET) and you&#8217;re doing some really fancy stuff, you might want to check on your page sizes&#8211;especially your viewstate. Those things can get huge.</p>
<p>Anyway, one of the commonly unnecessarily used controls, I think, is the LinkButton. When I had to try and make our pages a little leaner, that&#8217;s one of the first things I check:</p>
<div style="overflow:auto;">
<pre>&lt;asp:LinkButton ID="LinkButton1" runat="server" <span style="color: #ff6600;"><strong>PostBackUrl="~/somefolder/somepage.aspx"</strong></span>&gt;LinkButton&lt;/asp:LinkButton&gt;</pre>
</div>
<p>In our company, we had an (unrelated) viewstate problem where all our linkbuttons kept failing, but our A HREF tags were fine. Now, this made no sense to me &#8217;cause, basically, the above linkbutton was just doing the same job as an A HREF. There was no behind the code event subroutine, it was just a redirect.</p>
<p>I asked the programmer who did this why he didn&#8217;t use normal static A HREFs instead. He said that he wanted to be able to use the virtual path &#8220;~/&#8221; because the pages would be deployed in different plages at different stages. I introduced him to this nifty little library called <a title="VirtualPathUtility" href="http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx">VirtualPathUtility</a>.</p>
<p>You can get the same function by using this code:</p>
<div style="overflow:auto;">
<pre>&lt;a href="&lt;%=VirtualPathUtility.ToAbsolute("<span><strong><span style="color: #ff6600;"><strong>~/somefolder/somepage.aspx</strong></span></strong></span>")%&gt;"&gt;No Longer a LinkButton&lt;/a&gt;</pre>
</div>
<p>Because of the unrelated issue &#8212; and I might be wrong &#8212; but it seems like using a LinkButton even with a different PostBackURL specified, a postback to the same page DID occur, processed on the server, PostBackURL value determined, and then a redirection issue. To me, that&#8217;s like a lot more stuff going on that just a simple A HREF where the user clicks and the browser knows straight away which page it needs to go.</p>
<p>Plus, I think not having a webcontrol just means less for the server to keep track of since it&#8217;s all HTML that comes out. I could be wrong, but in our team, we&#8217;ve decided to apply the following:</p>
<p>1. Unless your LinkButton needs to do behind-the-code processing, convert all LinkButtons to &lt;a href&gt; tags.</p>
<p>2. If you need to resolve virtual paths, use the nifty VirtualPathUtility.</p>
<p>I&#8217;ve also used it to replace ImageButtons with &lt;a href&gt; and &lt;img&gt; tags. I&#8217;m not sure if it&#8217;s made a huge difference in the grand scheme of things, but hopefully it doesn&#8217;t hurt and helps just a little.</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=31" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Yikes! We went AWOL!</title>
		<link>http://twogeeks.mindchronicles.com/?p=30</link>
		<comments>http://twogeeks.mindchronicles.com/?p=30#comments</comments>
		<pubDate>Fri, 05 Sep 2008 14:33:26 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=30</guid>
		<description><![CDATA[Just realized it&#8217;s been ages since yuthavong or I have updated this blog and checked our comments! So sorry. I&#8217;ve responded to some comments on our most popular post about LINQ, I&#8217;m so sorry it was so late. Hopefully it can help future visitors. In the meantime, will try to check here more often. For [...]]]></description>
			<content:encoded><![CDATA[<p>Just realized it&#8217;s been ages since yuthavong or I have updated this blog and checked our comments! So sorry. I&#8217;ve responded to some comments on our most popular post about LINQ, I&#8217;m so sorry it was so late. Hopefully it can help future visitors. In the meantime, will try to check here more often. For some reason, the alerts on comments never reached us. So weird. Must bug yuthavong to get him to figure it out.</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=30" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;The file is too large for the destination file system.&#8221; &#8230;say what?</title>
		<link>http://twogeeks.mindchronicles.com/?p=29</link>
		<comments>http://twogeeks.mindchronicles.com/?p=29#comments</comments>
		<pubDate>Fri, 05 Sep 2008 14:10:33 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[computer]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=29</guid>
		<description><![CDATA[A few months ago, yuthavong bought a Western Digital 500GB My Book external hard disk. He tested it out and found out it was a bit too noisy for his tastes. So I gets it. Yay! I&#8217;m more tolerant of buzzing noises because my desktop has a constant buzz&#8211;but I have to admit,  the [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, <strong>yuthavong</strong> bought a <a href="http://www.wdc.com/en/products/products.asp?driveid=351">Western Digital 500GB My Book external hard disk</a>. He tested it out and found out it was a bit too noisy for his tastes. <em>So I gets it. Yay! </em>I&#8217;m more tolerant of buzzing noises because my desktop has a constant buzz&#8211;but I have to admit,  the My Book is a lot noisier than I expected and even I switch it off when I&#8217;m not using it.</p>
<p>Today, though, I decided to move off some of my Virtual Machine files to the My Book and clear up some of my hard disk. So I switched it on, plugged it in and tried to copy and paste it into the disk&#8230;</p>
<p>Windows tells me the file is too large for the destination file system. Bu-wha-? My virtual hard disks is over 4GB&#8230;but I checked! My Book had over 350GB free space! I thought it was the network problem (so I plugged it in direct), I thought it was read-only thing (resetting it did nothing), I was scratchin&#8217; my head until I Goggled and figured it out&#8230;.</p>
<p>The darn thing was formatted in FAT32. Did you know FAT32 doesn&#8217;t accept files larger than 4GB? Now WHY a 500GB storage space is formatted in FAT32 is beyond me!</p>
<p>But now, I&#8217;ve got a dilemma.</p>
<p>1) if this was a new disk, I&#8217;d be able to reformat it (Right clicking the Drive in My Computer and Format)</p>
<p>2) but I got data, &#8230; luckily, on a Windows, you can convert your disk on the fly!</p>
<p>a) Run the command prompt as Administrator (Start-&gt;Command Prompt-&gt;Right-click-&gt;Run as Administrator)</p>
<p>b) At the command prompt, type</p>
<pre>C:\Users\J&gt;convert <strong>f:</strong> /fs:ntfs /nosecurity</pre>
<p>where f: is the drive of your external hard disk.</p>
<p>And &#8230;tada! Two hours of trying to figure out what the heck was wrong, and fixed in 2 minutes.</p>
<p>Sooooo typical of a computer problem for ya.</p>
<p><strong>UPDATE: </strong>When prompted to &#8220;Enter the current volume label for drive [Drive Letter Here]&#8220;, if your drive has a label, you need to enter it (e.g. &#8220;My Passport&#8221; without the quotations). If your drive doesn&#8217;t have a label, just press the enter key for blank.</p>
<p>To find the volume label (if there is one specified), go to &#8216;My Computer&#8217;, right-click the drive you&#8217;re trying to convert, select Properties. In the General tab, the volume label is the name in the first field.</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=29" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=29</wfw:commentRss>
		<slash:comments>137</slash:comments>
		</item>
		<item>
		<title>LINQ, Stored Procedures and Multiple Recordsets: How-To</title>
		<link>http://twogeeks.mindchronicles.com/?p=28</link>
		<comments>http://twogeeks.mindchronicles.com/?p=28#comments</comments>
		<pubDate>Sat, 07 Jun 2008 12:47:57 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=28</guid>
		<description><![CDATA[Okay, here&#8217;s my entire test-run of how to get LINQ to work with stored procedures that return multiple recordsets just a dummy project.

Here&#8217;s a multiple recordset-returning stored procedure. My first recordset returns a three columns, single row of overview data, and my second recordset returns the list/breakdown.

 CREATE PROCEDURE spGetBookList
 AS
BEGIN
-- first recordset - overview [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, here&#8217;s my entire test-run of how to get LINQ to work with stored procedures that return multiple recordsets just a dummy project.</p>
<p><span id="more-28"></span><br />
Here&#8217;s a multiple recordset-returning stored procedure. My first recordset returns a three columns, single row of overview data, and my second recordset returns the list/breakdown.<br />
<code><br />
<span style="color: #0000ff;"> CREATE PROCEDURE</span> spGetBookList<br />
<span style="color: #0000ff;"> AS<br />
BEGIN</span><br />
-- first recordset - overview of the list<br />
<span style="color: #0000ff;">SELECT </span><span style="color: #ff00ff;">count</span>(*) <span style="color: #0000ff;">as </span>totalbooks,<br />
<span style="color: #ff00ff;">sum</span>(pages) <span style="color: #0000ff;">as </span>totalpages,<br />
<span style="color: #ff00ff;">sum</span>(price) <span style="color: #0000ff;">as </span>totalprice<br />
<span style="color: #0000ff;">from </span>book_list</code></p>
<p>&#8211; second recordset &#8211; the book list<br />
<span style="color: #0000ff;">select </span>id, title, author, pages, price, published_date<br />
<span style="color: #0000ff;">from </span>book_list<br />
<span style="color: #0000ff;">END</span><br />
GO</p>
<p>I want to use this through LINQ, so first, I&#8217;ve got to add it to the LINQ dbml file.</p>
<p><strong>1. Drag and drop in the designer as usual.<br />
</strong>The stored procedure will appear on the stored procedure list.</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/1.jpg"><img title="Add Stored Procedure into the DBML" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/1.jpg" alt="" width="215" height="163" /></a></p>
<p>The designer generates two things automatically whenever you drag a stored procedure. The function that you can use (in your coding) to call this stored procedure , and then the class that represents the data.</p>
<p>You can see this if you take a look at the .vb bile of the dbml file (expand the + sign on the dbml and double-click on the .vb file.).</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/21.jpg"><img class="alignnone size-medium wp-image-18" title="Double click on the .vb file" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/21.jpg" alt="" width="276" height="156" /></a></p>
<p>And scroll down &#8217;til you see a function that&#8217;s similar in name to the stored procedure you added.</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/31.jpg"><img class="alignnone size-full wp-image-20" title="Function and Data Class" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/31.jpg" alt="" /></a></p>
<p>Note:</p>
<ol>
<li>Public Function <strong>spGetBookList()</strong></li>
<li>Class spGetBookListResult</li>
</ol>
<p>As far as I can tell, this is what always happens when we drag a stored procedure to the designer. A function with the same name as the stored procedure will be created, and a class representing our recordset. Even though our stored procedure here returns two recordsets, the designer is only capable of detecting and designing one recordset result.</p>
<p>Here&#8217;s where I guess we have to go in and tweak it so that this function returns TWO recordset.</p>
<p><strong>2. Create a new class.<br />
</strong>This class is going to contain the data classes that&#8217;ll represent the multiple recordsets in our stored procedure.</p>
<p>At first I created these classes INSIDE the DBML&#8217;s .vb file, but I discovered I would lose all my tweaks/changes whenever I refreshed the DBML designer (e.g. adding a new table/stored procedure), since it generates that file automatically.</p>
<p>This is a pain here, but an important one: everytime the DBML is changed, it re-generates. That means, that some of the steps here will have to be re-done every time. More on that later. For now, though, this class will help reduce the number of steps that&#8217;ll have to be re-done.</p>
<p><strong>3. Move the partial class to the new class<br />
</strong></p>
<p><em>3a. </em>Insert Imports System.Data.Linq.Mapping to class</p>
<p><em>3b.</em> Cut and paste the partial public class spGetBookListResult from the .vb and paste into this new class.</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/4.jpg"><img class="alignnone size-medium wp-image-21" title="Partial Class" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/4-292x300.jpg" alt="" width="292" height="300" /></a></p>
<p><strong>4</strong><strong>. Create another partial class for the second recordset<br />
</strong>Basically this class has all the properties that&#8217;ll represent all the columns in the second recordset. Since my second statement was</p>
<p><code> <span style="color: #0000ff;">select </span>id, title, author, pages, price, published_date<br />
<span style="color: #0000ff;">from </span>book_list<br />
</code></p>
<p>My class had to have properties id (integer), title (string), author (string), pages (integer), price (decimal), published_date (datetime). Basically, you can pretty much copied the same format as the first recordset&#8217;s partial class and do something like this:</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/5.jpg"><img class="alignnone size-medium wp-image-22" title="Second Class" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/5-300x183.jpg" alt="" /></a></p>
<blockquote><p>CHEAT: To be honest, I don&#8217;t create most of my second-onwards recordset classes manually. What I do is I create a dummy stored procedure and put the single select statement into the stored procedure, drag it to the DBML, open the .vb, and tada, &#8220;steal&#8221; the auto-generated class for that select statement and put it in my own data class. And then I repeat as necessary, and when I&#8217;m done, I delete my dummy stored procedure from the DBML.</p></blockquote>
<p>Remember the name of this class!</p>
<p><strong>5</strong><strong>. Go back to the DBML .vb, find the function, and tweak it so that it returns the multiple recordset instead of one.<br />
</strong>To do this, you need to change this</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/6.jpg"><img class="alignnone size-full wp-image-23" title="Original Function" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/6.jpg" alt="" /></a></p>
<p>to this</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/7.jpg"><img class="alignnone size-full wp-image-24" title="7" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/7.jpg" alt="" /></a></p>
<p>Basically, the changes are:</p>
<ol>
<li>Replace the As ISingleResult(Of &lt;whateverclass) with IMultipleResults</li>
<li>Replace the function code with the one above Dim result &#8230;. Return Ctype(result.Returnvalue,IMultipleResults)</li>
<li>Add the ResultType attributes in order, with the GetType value referring to the class you just created to represent each recordset.</li>
</ol>
<p><strong>6</strong><strong>. Copy this entire function, paste into the data class, and comment out. JUST FOR REFERENCE.</strong></p>
<p>ANNNNNND, we&#8217;re done!</p>
<p>Oh, except on how to actually CALL this thing. Which would be something like this:</p>
<p><a href="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/82.jpg"><img class="alignnone size-full wp-image-27" title="Calling the function" src="http://twogeeks.mindchronicles.com/wp-content/uploads/2008/06/82.jpg" alt="" /></a></p>
<p>The results variable basically holds all the multiple recordsets. To access each one, you need to call the GetResult (in order), which is sort of like NextRecordset in good ol&#8217; ASP. The Of &lt;your recordset class&gt; allows you to do all those nice .&lt;fieldname&gt; intellisense and such.</p>
<p>I had to convert the results to ToList in order to iterate back and forth, but this may or may not be necessary in your case. Try with and without, YMMV.</p>
<p><strong>Oh, one more thing&#8230;<br />
</strong>Remember I said whenever you made a change to the DBML designer, the whole designer&#8217;s vb file gets regenerated? The IMultiple result function will ALSO disappear to be replaced by a single result one (and its data class). That&#8217;s where the copied Imultiple function in your own data class comes in handy. Just copy and replace and all will be well again.</p>
<p><strong>AND FIIIIINALLY&#8230;<br />
</strong>I get the feeling this is a bit hack-ish, especially the part where we&#8217;re going into the designer &#8211;that&#8217;s auto-generated&#8211; and then tweaking. Not sure if that&#8217;s the official proper way to do it&#8230; I look forward to the day when the designer will be a little bit more intuitive, generating the IMultiple result function and necessary classes itself. I would also love it if the designer could automatically REFRESH. (Ever notice that when you change a stored procedure after dragging it into the designer, you&#8217;ve got to remove and re-add?)</p>
<p><strong>The End.</strong></p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=28" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Maintenance Plans/Backup Jobs in SQL Server</title>
		<link>http://twogeeks.mindchronicles.com/?p=14</link>
		<comments>http://twogeeks.mindchronicles.com/?p=14#comments</comments>
		<pubDate>Thu, 22 May 2008 03:42:28 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[link-o-rama]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=14</guid>
		<description><![CDATA[Nice little tutorial here: 

Creating Backup Jobs in SQL Server 2005
SQL Server Tips: Shrinking Log

Will need to try.
Have gone a little crazy over current project&#8211;will be back during the next possible commercial break to blog about multiple results stored procedures and LINQ. Honest.


Click on pen to   var showHover=true;   
]]></description>
			<content:encoded><![CDATA[<p>Nice little tutorial here: </p>
<ul>
<li><a href="http://www.sql-server-performance.com/articles/dba/creating_backup_jobs_p1.aspx">Creating Backup Jobs in SQL Server 2005</a></li>
<li><a href="http://bloggingabout.net/blogs/mglaser/archive/2007/01/12/sql-server-tip-shrinking-a-sql-server-log.aspx">SQL Server Tips: Shrinking Log</a></li>
</ul>
<p>Will need to try.</p>
<p>Have gone a little crazy over current project&#8211;will be back during the next possible commercial break to blog about multiple results stored procedures and LINQ. Honest.</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=14" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ, Stored Procedures and Multiple Recordsets</title>
		<link>http://twogeeks.mindchronicles.com/?p=13</link>
		<comments>http://twogeeks.mindchronicles.com/?p=13#comments</comments>
		<pubDate>Thu, 15 May 2008 06:23:47 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[asp .net]]></category>
		<category><![CDATA[Guy Burstein]]></category>
		<category><![CDATA[link-o-rama]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[ScottGu]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=13</guid>
		<description><![CDATA[Update: This post has a follow up here: LINQ, Stored Procedures and Multiple Recordsets: How-To
I wanted to use a LINQ with a stored procedure that would return multiple recordsets, like this:

CREATE PROCEDURE spReturnMultiple
AS
   --first set
   SELECT value1 FROM table1
   --second set
   SELECT t1.value1, t2.value2
   FROM [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> This post has a follow up here: <a href="http://twogeeks.mindchronicles.com/?p=28">LINQ, Stored Procedures and Multiple Recordsets: How-To</a></p>
<p>I wanted to use a LINQ with a stored procedure that would return multiple recordsets, like this:</p>
<p><code><br />
CREATE PROCEDURE spReturnMultiple<br />
AS<br />
   --first set<br />
   SELECT value1 FROM table1</p>
<p>   --second set<br />
   SELECT t1.value1, t2.value2<br />
   FROM table1 t1 LEFT JOIN<br />
               table2 t2 on t1.value1 = t2.value2</p>
<p>GO<br />
</code></p>
<p> I found ScottGu&#8217;s <a href="http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx"> LINQ to SQL (Part 6 &#8211; Retrieving Data Using Stored Procedures)</a> article and Guy Burstein&#8217;s <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/10/05/linq-to-sql-stored-procedures-with-multiple-results-imultipleresults.aspx">Linq to SQL Stored Procedures with Multiple Results &#8211; IMultipleResults</a> article that pointed me into the right direction, but not QUITE all the way. </p>
<p>ScottGu&#8217;s article showed how you can use a SPROC to return different types of recordset (usually due to an IF statement within the SPROC) and how IMultipleResults were used; in the comment trail someone asks about multiple tables and ScottGu said it could be done in the same way, calling GetResult twice. Burstein&#8217;s article showed exactly how you did this. My problem was that the stored procedures returned TABLES. However, my results are based on my own SELECT statements, so there was a little bit of extra that had to be done.<br />
<span id="more-13"></span><br />
HOW TO (overview):</p>
<ol>
<li>Create the multiple recordset stored procedure</li>
<li>Drag the stored procedure into the DBML. <em>Note, this will create the functions and classes for retrieving the first recordset.</em></li>
<li>For each recordset, create the partial class needed based on the columns returned. Use the first recordset&#8217;s class as a guide.</li>
<li>Now that you&#8217;ve got all your recordset classes, convert the function for the stored procedure into IMultipleResults</li>
<li>In the application layer, call the stored procedure and use GetResults (and the recordset class) to access the multiple results.<em>Self-note: had to convert the results ToList() in order to use it/iterate later,etc.</em></li>
</ol>
<p>I&#8217;ll come back here and illustrate each step later. Need to finish up that page now that I&#8217;ve got access to my multiple results!</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=13" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ScottGu &#8211; Da LINQ Man!</title>
		<link>http://twogeeks.mindchronicles.com/?p=12</link>
		<comments>http://twogeeks.mindchronicles.com/?p=12#comments</comments>
		<pubDate>Thu, 15 May 2008 04:21:24 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[link-o-rama]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[ScottGu]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=12</guid>
		<description><![CDATA[For my own reference, the various parts of ScottGu&#8217;s LINQ series:

Part 1: Introduction to LINQ to SQL
Part 2: Defining our Data Model Classes
Part 3: Querying our Database
Part 4: Updating our Database
Part 5: Binding UI using the ASP:LinqDataSource Control
Part 6: Retrieving Data Using Stored Procedures
Part 7: Updating our Database using Stored Procedures
Part 8: Executing Custom SQL [...]]]></description>
			<content:encoded><![CDATA[<p>For my own reference, the various parts of ScottGu&#8217;s LINQ series:</p>
<ul><span style="font-family: arial; font-size: x-small;"></p>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx" target="_blank">Part 1: Introduction to LINQ to SQL</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx" target="_blank">Part 2: Defining our Data Model Classes</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx" target="_blank">Part 3: Querying our Database</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx" target="_blank">Part 4: Updating our Database</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx" target="_blank">Part 5: Binding UI using the ASP:LinqDataSource Control</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx" target="_blank">Part 6: Retrieving Data Using Stored Procedures</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/23/linq-to-sql-part-7-updating-our-database-using-stored-procedures.aspx" target="_blank">Part 7: Updating our Database using Stored Procedures</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx" target="_blank">Part 8: Executing Custom SQL Expressions</a></li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx">Part 9: Using a Custom LINQ Expression with the &lt;asp:LinqDatasource&gt; control</a></li>
<p></span></ul>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=12" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005&#8217;s Pivot&#8230;PIVOT, PIVVOOOOT &#8211; Ross Gellar, Friends</title>
		<link>http://twogeeks.mindchronicles.com/?p=11</link>
		<comments>http://twogeeks.mindchronicles.com/?p=11#comments</comments>
		<pubDate>Fri, 09 May 2008 06:54:33 +0000</pubDate>
		<dc:creator>juliana</dc:creator>
				<category><![CDATA[I Canz Code!]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://twogeeks.mindchronicles.com/?p=11</guid>
		<description><![CDATA[Every time I see SQL Server&#8217;s 2005 PIVOT, I think of that episode of Friends where Ross tries to guide his friends as they bring up the couch to his apartment.

But serious, PIVOT is one of those things that I&#8217;m still trying to wrap my brain around.
I&#8217;m currently digesting this: Pivots with Dynamic Columns in [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I see SQL Server&#8217;s 2005 PIVOT, I think of that episode of <em>Friends</em> where Ross tries to guide his friends as they bring up the couch to his apartment.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="wmode" value="transparent" /><param name="src" value="http://www.youtube.com/v/B_PklVas9cA&amp;hl=en" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/B_PklVas9cA&amp;hl=en" wmode="transparent"></embed></object></p>
<p>But serious, PIVOT is one of those things that I&#8217;m still trying to wrap my brain around.</p>
<p>I&#8217;m currently digesting this: <a href="http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx">Pivots with Dynamic Columns in SQL Server 2005</a></p>
<p>and modified this examples into one script with temporary tables so I can study it better:</p>
<p><span id="more-11"></span></p>
<p>DECLARE  @Table1 TABLE (ColId INT,ColName VARCHAR(10))<br />
INSERT INTO @Table1 VALUES(1, &#8216;Country&#8217;)<br />
INSERT INTO @Table1 VALUES(2, &#8216;Month&#8217;)<br />
INSERT INTO @Table1 VALUES(3, &#8216;Day&#8217;)</p>
<p>DECLARE @cols NVARCHAR(2000)<br />
SELECT  @cols = COALESCE(@cols + &#8216;,[' + colName + ']&#8216;,<br />
&#8216;[' + colName + ']&#8216;)<br />
FROM    @Table1<br />
ORDER BY colName</p>
<p>DECLARE  @Table2 TABLE (tID INT,ColID INT,Txt VARCHAR(10))<br />
INSERT INTO @Table2 VALUES (1,1, &#8216;US&#8217;)<br />
INSERT INTO @Table2 VALUES (1,2, &#8216;July&#8217;)<br />
INSERT INTO @Table2 VALUES (1,3, &#8216;4&#8242;)<br />
INSERT INTO @Table2 VALUES (2,1, &#8216;US&#8217;)<br />
INSERT INTO @Table2 VALUES (2,2, &#8216;Sep&#8217;)<br />
INSERT INTO @Table2 VALUES (2,3, &#8216;11&#8242;)<br />
INSERT INTO @Table2 VALUES (3,1, &#8216;US&#8217;)<br />
INSERT INTO @Table2 VALUES (3,2, &#8216;Dec&#8217;)<br />
INSERT INTO @Table2 VALUES (3,3, &#8216;25&#8242;)</p>
<p>SELECT    t2.tID<br />
, t1.ColName<br />
, t2.Txt<br />
FROM      @Table1 AS t1<br />
JOIN @Table2<br />
AS t2 ON t1.ColId = t2.ColID</p>
<p>SELECT  tID<br />
, [Country]<br />
, [Day]<br />
, [Month]<br />
FROM    ( SELECT    t2.tID<br />
, t1.ColName<br />
, t2.Txt<br />
FROM      @Table1 AS t1<br />
JOIN @Table2<br />
AS t2 ON t1.ColId = t2.ColID<br />
) p PIVOT ( MAX([Txt])<br />
FOR ColName IN ( [Country], [Day],<br />
[Month] ) ) AS pvt<br />
ORDER BY tID ;</p>

<!-- RoohIt Button BEGIN -->
<div class="roohit_container" style=" height:30px;"><span style="background-color:#ffff00; font-weight:float:left; text-align:left;">Click on pen to</span> <a class="roohitBtn" href="http://roohit.com/http://twogeeks.mindchronicles.com/?p=11" title="Use a Highlighter on this page"><img src="http://roohit.com/images/btns/h20/01_HTP.png" border="0" alt="Use a Highlighter on this page" style="border:none; vertical-align:middle;"/></a><script type="text/javascript">  var showHover=true;  </script> <script type="text/javascript" src="http://roohit.com/site/btn.js"></script></div>
<!-- RoohIt Button END -->]]></content:encoded>
			<wfw:commentRss>http://twogeeks.mindchronicles.com/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
