<?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"
	>

<channel>
	<title>Enterprise Software Development</title>
	<atom:link href="http://www.devprise.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devprise.com</link>
	<description>by devprise.com</description>
	<pubDate>Wed, 18 Jun 2008 14:41:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>How To Install Windows Live Writer on Windows Server 2008</title>
		<link>http://www.devprise.com/2008/06/18/howto-install-windows-live-writer-on-windows-server-2008/</link>
		<comments>http://www.devprise.com/2008/06/18/howto-install-windows-live-writer-on-windows-server-2008/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 14:40:32 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2008/06/18/howto-install-windows-live-writer-on-windows-server-2008/</guid>
		<description><![CDATA[So this is my first post using Windows Live Writer from a Windows Server 2008 workstation.
I was not able to install Windows Live Writer 2008 on my server workstation, it would give the error:
Sorry, Windows Live programs cannot be installed on Windows Server, Windows XP Professional x64 Edition, or Windows operating systems earlier than Windows [...]]]></description>
			<content:encoded><![CDATA[<p>So this is my first post using Windows Live Writer from a <a href="http://weblogs.asp.net/israelio/archive/2008/02/21/windows-server-2008-as-workstation.aspx">Windows Server 2008 workstation</a>.</p>
<p>I was not able to install Windows Live Writer 2008 on my server workstation, it would give the error:</p>
<p><font color="#ff0000">Sorry, Windows Live programs cannot be installed on Windows Server, Windows XP Professional x64 Edition, or Windows operating systems earlier than Windows XP Service Pack 2.</font></p>
<p>BUT you <strong>CAN</strong> install the <a href="http://windowslivewriter.spaces.live.com/blog/cns!D85741BB5E0BE8AA!1508.entry">Technical Preview version</a> on Windows Server 2008 !!!</p>
<p>Need a good book on Windows Server 2008, see <a type="amzn" asin="0672329301">Windows Server 2008 Unleashed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/06/18/howto-install-windows-live-writer-on-windows-server-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Copy / Clone a Hyper-V Virtual Machine</title>
		<link>http://www.devprise.com/2008/06/17/how-to-copy-clone-a-hyper-v-virtual-machine/</link>
		<comments>http://www.devprise.com/2008/06/17/how-to-copy-clone-a-hyper-v-virtual-machine/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 15:24:03 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.devprise.com/?p=60</guid>
		<description><![CDATA[You can create a copy or clone of an existing virtual machine (VM) quite easily in Hyper-V &#8230; The process is a little different than you might think though. The basic procedure is to export and import a virtual machine. I use my VM&#8217;s primarily for separate development sandboxes and test machines, so here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<p>You can create a copy or clone of an existing virtual machine (VM) quite easily in Hyper-V &#8230; The process is a little different than you might think though. The basic procedure is to export and import a virtual machine. I use my VM&#8217;s primarily for separate development sandboxes and test machines, so here&#8217;s the steps I used:</p>
<ol>
<li>Sysprep the guest VM (for windows machines)</li>
<li>Shut down the guest</li>
<li>Rename the VM to &#8220;Dev Ws - Base&#8221; (in Hyper-V Manager)</li>
<li>Hyper-V Export Virtual Machine</li>
<li>Rename the original VM back to the original name</li>
<li>Make a copy of the exported directory in windows explorer (optional if you want more than one copy) (i used robocopy from an administrator command prompt [robocopy /s "Dev Ws - Base" "Dev Ws - SplendidCRM"])</li>
<li>Import the one of the directories</li>
<li>Rename the new VM to your new VM name, in my case it was &#8220;Dev Ws - DotNetNuke&#8221;</li>
</ol>
<p>Now you should have multiple copies of your original VM. <a type="amzn" asin="0470174595">Check out Microsoft Windows Server 2008: Implementation and Administration</a> for more information on Hyper-V!</p>
<p>Oh and if you want to move the exported folder for any reason before you re-import it, you might need to stop the Hyper-V service, other wise you may get a &#8220;destination folder access denied&#8221; error box.</p>
<p>If you want a scripted solution to this (like to make lets say 10 machines) <a href="http://blogs.technet.com/virtualization/archive/2008/06/07/hyper-v-wmi-cloning-virtual-machines-using-import-export.aspx">check out this post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/06/17/how-to-copy-clone-a-hyper-v-virtual-machine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Excel ODBC Driver for Windows Server 2008 (64 Bit)</title>
		<link>http://www.devprise.com/2008/06/10/excel-odbc-driver-for-windows-server-2008/</link>
		<comments>http://www.devprise.com/2008/06/10/excel-odbc-driver-for-windows-server-2008/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 17:20:48 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2008/06/10/excel-odbc-driver-for-windows-server-2008/</guid>
		<description><![CDATA[So I&#8217;m running Windows Server 2008 as a development workstation. I ran into some trouble with a custom .NET application that imports data from Excel files using the ODBC driver.
Error Message in .NET
ERROR [IM002] [Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified
We are using this ODBC connection string (found [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m running <a href="http://blogs.msdn.com/vijaysk/archive/2008/02/11/using-windows-server-2008-as-a-super-desktop-os.aspx">Windows Server 2008 as a development workstation</a>. I ran into some trouble with a custom .NET application that imports data from Excel files using the ODBC driver.</p>
<h3>Error Message in .NET</h3>
<p><font color="#ff0000">ERROR [IM002] [Microsoft] [ODBC Driver Manager] Data source name not found and no default driver specified</font></p>
<p>We are using this ODBC connection string (found on <a href="http://www.connectionstrings.com">connectionsstrings.com</a>):</p>
<p><font face="Courier New" size="2">Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDir=c:\mypath;</font> </p>
<p>After much research on the issue, it turns out the Excel ODBC drivers are 32 bit. So you need to change your Visual Studio platform to be x86 (to force 32bit) &#8230; mine was set to &#8220;Any CPU&#8221;</p>
<p>From what I can gather about the issue here, is that if your application is running in 64 bit mode, then when it creates an odbcConnection, that will also be running under 64 bit (makes sense so far) &#8230; so for any drivers that you have that are 32 bit they will not be accessible. Thus you get an error stating &#8220;data source name not found&#8221;</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3385836&amp;SiteID=1">see this forum post about running sql server 2005 64 bit &#8230; it doesn&#8217;t say anything about Excel, but I think the principle applies</a></p>
<p>That&#8217;s it! Hope this helps.</p>
<p><a type="amzn" asin="0735623619">For some light <img src='http://www.devprise.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> reading on Windows Server 2008</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/06/10/excel-odbc-driver-for-windows-server-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Small Simple Plug-In to Burn ISO&#8217;s in Windows Vista</title>
		<link>http://www.devprise.com/2008/06/02/small-simple-plug-in-to-burn-isos-in-windows-vista/</link>
		<comments>http://www.devprise.com/2008/06/02/small-simple-plug-in-to-burn-isos-in-windows-vista/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 16:23:50 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Audio / Video]]></category>

		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2008/06/02/small-simple-plug-in-to-burn-isos-in-windows-vista/</guid>
		<description><![CDATA[For a very small simple and easy to use ISO burner for Windows Vista (and XP), check out ISO Recorder by Alex Feinman &#8230; It works like a Microsoft PowerToy. I love it!
]]></description>
			<content:encoded><![CDATA[<p>For a very small simple and easy to use ISO burner for Windows Vista (and XP), check out <a href="http://isorecorder.alexfeinman.com/isorecorder.htm">ISO Recorder by Alex Feinman</a> &#8230; It works like a Microsoft PowerToy. I love it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/06/02/small-simple-plug-in-to-burn-isos-in-windows-vista/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HowTo Filter System.IO.Directory.GetFiles with Linq</title>
		<link>http://www.devprise.com/2008/05/30/howto-filter-systemiodirectorygetfiles-with-linq/</link>
		<comments>http://www.devprise.com/2008/05/30/howto-filter-systemiodirectorygetfiles-with-linq/#comments</comments>
		<pubDate>Fri, 30 May 2008 19:58:09 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[linq filter getfiles howto easy simple system.io direct]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2008/05/30/howto-filter-systemiodirectorygetfiles-with-linq/</guid>
		<description><![CDATA[Here we are going to see an easy way to enumerate files in a directory, filter the files with Linq, then bind the results to a ASP.NET repeater control. We will show you the old .NET 1x way of doing this, then the new and improved Linq way of doing this.
I had a method that [...]]]></description>
			<content:encoded><![CDATA[<p>Here we are going to see an easy way to enumerate files in a directory, filter the files with Linq, then bind the results to a ASP.NET repeater control. We will show you the old .NET 1x way of doing this, then the new and improved Linq way of doing this.</p>
<p>I had a method that would return a DataTable as results, then bind it to a ASP.NET Repeater control to display the file list of Exception Reports.</p>
<h2>Old .NET 1.1 way of filtering a GetFiles list and returning as a bindable object</h2>
<div style="border-right: lightblue 1px solid; padding-right: 3px; border-top: lightblue 1px solid; padding-left: 3px; font-size: 10pt; background: white; padding-bottom: 3px; margin: 5px; border-left: lightblue 1px solid; color: black; padding-top: 3px; border-bottom: lightblue 1px solid; font-family: courier new">
<p style="margin: 0px"><span style="color: #2b91af">DataTable</span> dtFiles = <span style="color: blue">new</span> <span style="color: #2b91af">DataTable</span>();</p>
<p style="margin: 0px">dtFiles.Columns.Add(<span style="color: #a31515">&quot;FullName&quot;</span>, <span style="color: blue">typeof</span>(<span style="color: blue">string</span>));</p>
<p style="margin: 0px">dtFiles.Columns.Add(<span style="color: #a31515">&quot;FileName&quot;</span>, <span style="color: blue">typeof</span>(<span style="color: blue">string</span>));</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">foreach</span> (<span style="color: blue">string</span> file <span style="color: blue">in</span> <span style="color: #2b91af">Directory</span>.GetFiles(Server.MapPath(<span style="color: #a31515">&quot;~/App_Data&quot;</span>)))</p>
<p style="margin: 0px">{</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">if</span> (!file.Contains(<span style="color: #a31515">&quot;ErrorReport&quot;</span>))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">continue</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: #2b91af">DataRow</span> row = dtFiles.NewRow();</p>
<p style="margin: 0px">&#160;&#160;&#160; row[<span style="color: #a31515">&quot;FullName&quot;</span>] = file;</p>
<p style="margin: 0px">&#160;&#160;&#160; row[<span style="color: #a31515">&quot;FileName&quot;</span>] = System.IO.<span style="color: #2b91af">Path</span>.GetFileName(file);</p>
<p style="margin: 0px">&#160;&#160;&#160; dtFiles.Rows.Add(row);</p>
<p style="margin: 0px">}</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">this</span>.repeaterFiles.DataSource = dtFiles;</p>
<p style="margin: 0px"><span style="color: blue">this</span>.repeaterFiles.DataBind();</p>
</p></div>
<p>&#160;</p>
<h2>Here is how to filter your GetFiles results with Linq</h2>
<div style="border-right: lightblue 1px solid; padding-right: 3px; border-top: lightblue 1px solid; padding-left: 3px; font-size: 10pt; background: white; padding-bottom: 3px; margin: 5px; border-left: lightblue 1px solid; color: black; padding-top: 3px; border-bottom: lightblue 1px solid; font-family: courier new">
<p style="margin: 0px"><span style="color: blue">var</span> fileList = <span style="color: blue">from</span> file <span style="color: blue">in</span> <span style="color: #2b91af">Directory</span>.GetFiles(Server.MapPath(<span style="color: #a31515">&quot;~/App_Data&quot;</span>))</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">where</span> file.Contains(<span style="color: #a31515">&quot;ErrorReport&quot;</span>)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">select</span> <span style="color: blue">new</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; FullName = file,</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; FileName = System.IO.<span style="color: #2b91af">Path</span>.GetFileName(file)</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; };</p>
<p style="margin: 0px"><span style="color: blue">this</span>.repeaterFiles.DataSource = dtFiles;</p>
<p style="margin: 0px"><span style="color: blue">this</span>.repeaterFiles.DataBind();</p>
</p></div>
<p>You can see this is much cleaner, no need to create a DataTable with the results. By using the &quot;select new&quot; you are basically creating a collection with two properties (FullName, FileName) on the fly.</p>
<p>I found <a type="amzn" asin="1590597893">Pro LINQ</a> to be an excellent read on the Linq subject.</p>
<p>  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" id="Player_2807d9c1-2c63-4263-b9e0-7e0b434b11ba"  WIDTH="600px" HEIGHT="200px"><param NAME="movie" VALUE="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822%2FUS%2Fenterprises0e-20%2F8010%2F2807d9c1-2c63-4263-b9e0-7e0b434b11ba&amp;Operation=GetDisplayTemplate"></param><param NAME="quality" VALUE="high"></param><param NAME="bgcolor" VALUE="#FFFFFF"></param><param NAME="allowscriptaccess" VALUE="always"><embed src="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822%2FUS%2Fenterprises0e-20%2F8010%2F2807d9c1-2c63-4263-b9e0-7e0b434b11ba&amp;Operation=GetDisplayTemplate" id="Player_2807d9c1-2c63-4263-b9e0-7e0b434b11ba" quality="high" bgcolor="#ffffff" name="Player_2807d9c1-2c63-4263-b9e0-7e0b434b11ba" allowscriptaccess="always" type="application/x-shockwave-flash" align="middle" height="200px" width="600px"></embed></param></object> <noscript><a HREF="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822%2FUS%2Fenterprises0e-20%2F8010%2F2807d9c1-2c63-4263-b9e0-7e0b434b11ba&amp;Operation=NoScript">Amazon.com Widgets</a></noscript></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/05/30/howto-filter-systemiodirectorygetfiles-with-linq/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Querying Selected Items From ListItemCollection Using Lambda Expressions</title>
		<link>http://www.devprise.com/2008/05/27/querying-selected-items-from-listitemcollection-using-lambda/</link>
		<comments>http://www.devprise.com/2008/05/27/querying-selected-items-from-listitemcollection-using-lambda/#comments</comments>
		<pubDate>Tue, 27 May 2008 20:10:09 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[linq lambda expressions .net framework 3.5 listbox list]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2008/05/27/querying-selected-items-from-listitemcollection-using-lambda/</guid>
		<description><![CDATA[You can use Linq and Lambda expressions along with the new extensions provided in the .NET framework 3.5 to filter those old school specialized collections like ListItemCollection. The key is to first convert the collection to a generic list using the Cast or ToList extension methods .... more on this in this article]]></description>
			<content:encoded><![CDATA[<p>You can use Lambda expressions and the new extensions provided in the .NET framework 3.5 to filter your specialized collections like the ListItemCollection (used in ASP.NET ListBox controls).</p>
<p>I found this great usage for lambda this weekend when posed with a problem using a ListBox control with a SelectionMode of Multiple. If you&#8217;ve ever worked with the ListBox before (and I think you have), getting the single SelectedValue or SelectedIndex is a piece of cake. When you need to get all the selected items, well now you&#8217;re probably thinking about using a foreach loop to find the selected items, list this:</p>
<h2>Two &#8216;old school&#8217; solutions to get Selected items from a ListItemCollection</h2>
<h3></h3>
<h3>Simple foreach loop for finding Selected items in a ListItemCollection</h3>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">List&lt;ListItem&gt; selectedItems = <span style="color: #0000ff">new</span> List&lt;ListItem&gt;();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">foreach</span> (ListItem itm <span style="color: #0000ff">in</span> lboxItems.Items)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">if</span> (itm.Selected)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        selectedItems.Add(itm);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
</p></div>
</div>
<p>Or you&#8217;re thinking about using an Iterator pattern here, made easy with .NET framework 2.0 and the lovely generics it brought us:</p>
<h3>More advanced Iterator patten for returning only selected items</h3>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">private</span> IEnumerable&lt;ListItem&gt; selectedItems(ListBox lbox)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">foreach</span> (ListItem itm <span style="color: #0000ff">in</span> lbox.Items)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">if</span> (itm.Selected)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">yield</span> <span style="color: #0000ff">return</span> itm;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }            </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
</p></div>
</div>
<h2>Welcome to Lambda and .NET framework 3.5 !!!</h2>
<p>Can you tell that I am overly excited about this?</p>
<p>So there is two more ways to do this:</p>
<h3>How to get only the selected items from a ListBox control using Linq</h3>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">var selectedItems = from li <span style="color: #0000ff">in</span> lboxItems.Items.Cast&lt;ListItem&gt;()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">where</span> li.Selected == <span style="color: #0000ff">true</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    select li;</pre>
</p></div>
</div>
<p>You see we have to first Cast the specialized ListItemCollection to a generic List&lt;ListItem&gt; collection before it can be used in a Linq query (for more info on linq <a type="amzn" asin="1590597893">this book</a> really helped me on the subject). You may even want to finally encapsulate the (from &#8230;. select li) with parenthesis and then apply a .ToList(), that way it will be typed as a Generic List&lt;ListItem&gt; collection.</p>
<h3>How to get only the selected items from a ListBox control using Lambda Expressions</h3>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">List&lt;ListItem&gt; selectedItems =</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    lboxItems.Items.Cast&lt;ListItem&gt;()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    .Where(itm =&gt; itm.Selected == <span style="color: #0000ff">true</span>).ToList();</pre>
</p></div>
</div>
<p>You see we also had to first Cast the specialized ListItemCollection to a generic List&lt;ListItem&gt; collection first to get the extensions (Where and ToList) &#8230; now in the Where method is the place that we finally see the lambda expression come to light, this basically is an easier way to express an anonymous delagate function, if you&#8217;ve never used one before, then feel lucky that your here now with the availablility of lambda!!!</p>
<p>&#160;</p>
<p>You can download a working <a href="/files/LambaDemoListItemCollection.zip">Lamda demo against ListItemCollection here</a></p>
<p>&#160;</p>
<p>I highly recommend <a type="amzn" asin="0672330113">ASP.NET 3.5 Unleashed</a> which talks a lot about Linq and Lamda expressions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2008/05/27/querying-selected-items-from-listitemcollection-using-lambda/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SQLTRACE_BUFFER_FLUSH, Performance Metrics on SQL Server 2005</title>
		<link>http://www.devprise.com/2007/12/10/sqltrace_buffer_flush-performance-metrics-on-sql-server-2005/</link>
		<comments>http://www.devprise.com/2007/12/10/sqltrace_buffer_flush-performance-metrics-on-sql-server-2005/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 16:55:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2007/12/10/sqltrace_buffer_flush-performance-metrics-on-sql-server-2005/</guid>
		<description><![CDATA[Tuning your SQL 2005 Database with built in metrics.]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2005 gathers metrics data for you automatically out of the box! I discovered this bit of information today, as I was looking into why my DotNetNuke database was starting to drag down. (remember my previous post about <a href="http://www.devprise.com/2006/09/26/how-to-reset-a-dnn-password-at-the-database/">How to reset a DNN password at the Database</a>)</p>
<p>I started by looking at some of the hidden metrics data that SQL Server 2005 collects out of the box for you. The first thing to look at was to run a query about the causes of the wait times, to do this execute the following query.</p>
<p class="tcode">select top 10   <br /> wait_type &quot;Wait Type&quot;,    <br /> wait_time_ms / 1000 &quot;Wait time (s)&quot;,    <br /> Convert(Decimal(12,2), wait_time_ms * 100.0    <br /> / Sum(wait_time_ms) over ()) &quot;% Waiting&quot;    <br /> from sys.dm_os_wait_stats    <br /> where wait_type not like &#8216;%SLEEP%&#8217;    <br /> order by wait_time_ms desc</p>
<p>This query did not tell me a very much, except that SQLTRACE_BUFFER_FLUSH was at the top of the scale with 99.92% of the wait time.</p>
<p>So I moved on to a more complex query to show a list of missing indexes. This is an interesting query, and it proved to be the one that fixed the slowness problems on my DotNetNuke database.</p>
<p>Here is the query I used to show the cost of missing Indexes</p>
<p class="tcode">select top 10   <br /> round(avg_total_user_cost * avg_user_impact    <br /> * (user_seeks + user_scans), 0) &quot;Total Cost&quot;,    <br /> avg_user_impact, statement &quot;Table Name&quot;,    <br /> equality_columns &quot;Equality Columns&quot;,    <br /> inequality_columns &quot;Inequality Columns&quot;,    <br /> included_columns &quot;Include Columns&quot;    <br /> from sys.dm_db_missing_index_groups g    <br /> join sys.dm_db_missing_index_group_stats s    <br /> on s.group_handle = g.index_group_handle    <br /> join sys.dm_db_missing_index_details d    <br /> on d.index_handle = g.index_handle    <br /> order by &quot;Total Cost&quot; desc;</p>
<p><a type="amzn" asin="0470176393">Read this for an excellent book on SQL Server 2005 Performance Tuning</a> For more information on Performance Tuning Another great article on the impact of SQLTRACE_BUFFER_FLUSH is found <a href="http://sqlblog.com/blogs/linchi_shea/archive/2007/01/16/performance-impact-of-enabling-page-checksum-and-default-trace.aspx?CommentPosted=true" rel="nofollow">Here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2007/12/10/sqltrace_buffer_flush-performance-metrics-on-sql-server-2005/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET 2.0 Generic Collections to 1.0 and 1.1 Collections</title>
		<link>http://www.devprise.com/2007/10/22/net-20-generic-collections-to-10-and-11-collections/</link>
		<comments>http://www.devprise.com/2007/10/22/net-20-generic-collections-to-10-and-11-collections/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 18:28:48 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[.NET Programming]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2007/10/22/net-20-generic-collections-to-10-and-11-collections/</guid>
		<description><![CDATA[I am always looking around for the Generic equivalents for the non-generic collections. Especially when converting 1.1 code over to 2.0

.comptable td
{
	border-bottom: 1px solid #008000;
	background-color: #ebf7ff;
}
.comptable .name
{
	background-color: #a8cece;
}

Table of Generic Collections to Non-Generic Collections


Non-Generic (1.x)
Generic Replacements (2.0+)


ArrayList
List&#60;T&#62;


CollectionBase
Collection&#60;T&#62;


Comparer
Comparer&#60;T&#62;


CompatibleComparer
Comparer&#60;T&#62;


DictionaryBase
KeyedCollection&#60;TKey,TItem&#62;


Hashtable
Dictionary&#60;TKey,TValue&#62;


ICollection
ICollection&#60;T&#62;


IDictionary
IDictionary&#60;TKey,TValue&#62;


IList
IList&#60;T&#62;


Queue
Queue&#60;T&#62;


ReadOnlyCollectionBase
ReadOnlyCollection&#60;T&#62;


SortedList
SortedList&#60;TKey, TValue&#62;


Stack
Stack&#60;T&#62;


&#xA0;
&#xA0;



&#xA0;
Performance
List&#60;T&#62; : a List&#60;T&#62; uses an underlying array that maintains order, thus inserting and removing from this object [...]]]></description>
			<content:encoded><![CDATA[<p>I am always looking around for the Generic equivalents for the non-generic collections. Especially when converting 1.1 code over to 2.0</p>
<style>
.comptable td
{
	border-bottom: 1px solid #008000;
	background-color: #ebf7ff;
}
.comptable .name
{
	background-color: #a8cece;
}</style>
<table class="comptable" cellspacing="0" cellpadding="2" width="600">
<caption>Table of Generic Collections to Non-Generic Collections</caption>
<tbody>
<tr>
<td class="name" valign="top" width="300"><b>Non-Generic (1.x)</b></td>
<td valign="top" width="300"><b>Generic Replacements (2.0+)</b></td>
</tr>
<tr>
<td class="name" valign="top" width="300">ArrayList</td>
<td valign="top" width="300">List&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">CollectionBase</td>
<td valign="top" width="300">Collection&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">Comparer</td>
<td valign="top" width="300">Comparer&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">CompatibleComparer</td>
<td valign="top" width="300">Comparer&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">DictionaryBase</td>
<td valign="top" width="300">KeyedCollection&lt;TKey,TItem&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">Hashtable</td>
<td valign="top" width="300">Dictionary&lt;TKey,TValue&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">ICollection</td>
<td valign="top" width="300">ICollection&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">IDictionary</td>
<td valign="top" width="300">IDictionary&lt;TKey,TValue&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">IList</td>
<td valign="top" width="300">IList&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">Queue</td>
<td valign="top" width="300">Queue&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">ReadOnlyCollectionBase</td>
<td valign="top" width="300">ReadOnlyCollection&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">SortedList</td>
<td valign="top" width="300">SortedList&lt;TKey, TValue&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">Stack</td>
<td valign="top" width="300">Stack&lt;T&gt;</td>
</tr>
<tr>
<td class="name" valign="top" width="300">&#xA0;</td>
<td valign="top" width="300">&#xA0;</td>
</tr>
</tbody>
</table>
<p>&#xA0;</p>
<h2>Performance</h2>
<p>List&lt;T&gt; : a List&lt;T&gt; uses an underlying array that maintains order, thus inserting and removing from this object can take a variable amount of time.</p>
<p>Dictionary&lt;TKey,TValue&gt; : a Dictionary&lt;TKey,TValue&gt; is generally average with add, remove, and contains, even when it contains a large set of data.</p>
<p>SortedDictionary&lt;Tkey,TValue&gt; : SortedDictionary&lt;Tkey,TValue&gt; uses a balanced tree as the underlying implementation. This can provide you with fast lookups, but inserting will more than likely be slower.</p>
<p>SortedList&lt;TKey,TValue&gt; : SortedList&lt;TKey,TValue&gt; uses two separate arrays to store the data, both in order.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2007/10/22/net-20-generic-collections-to-10-and-11-collections/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Streaming Video From Home to Work</title>
		<link>http://www.devprise.com/2007/09/18/streaming-video-from-home-to-work/</link>
		<comments>http://www.devprise.com/2007/09/18/streaming-video-from-home-to-work/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 15:53:33 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Audio / Video]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2007/09/18/streaming-video-from-home-to-work/</guid>
		<description><![CDATA[Setting up an audio/video stream using VLC. Stream your DVDs or your favorite TV shows to your office PC.]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to stream some video from your house to a remote location. Like to your cell phone, or to your computer at work? Maybe you are scheduled to work late during the World Cup, or NBA Finals. Well here is a simple way to stream that video/audio using <a href="http://www.videolan.org/" rel="nofollow">VLC (VideoLAN media player)</a>.</p>
<h2>Requirements:</h2>
<ul>
<li>A knowledge of how to open ports on your home router / home computer firewall </li>
<li><a href="http://www.videolan.org/" rel="nofollow">VLC</a> (at the time of this article we used 0.8.6c for windows) </li>
</ul>
<h3></h3>
<h2>The source PC:</h2>
<h3>VLC Source Settings</h3>
<ul>
<li>Start VLC </li>
<li>Click on File &#8230; Open </li>
<li>Click on the tab that will be your source
<ul>
<li><strong>File</strong> - You can even open DVD ISO&#8217;s with this one </li>
<li><strong>Disc</strong> - You can use a DVD disc as the source (this is a little weird though since you will not be able to control the DVD menu remotely) </li>
<li><strong>DirectShow</strong> - This is if you would want to stream from a hardware video source, like a webcam, or even a TV Tuner (like my DViCO HDTV 5 Lite clear QAM tuner) </li>
</ul>
</li>
<li>After you pick your source, we need to do some work on the advanced panel beneath your source. </li>
<li>Click on the <strong>Stream/Save</strong> checkbox </li>
<li>Click on the <strong>Settings&#8230;</strong> button<a href="http://www.devprise.com/wp-content/uploads/2007/09/image.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="215" alt="VLC Streaming/Save settings" src="http://www.devprise.com/wp-content/uploads/2007/09/image-thumb.png" width="204" align="right" border="0" /></a> </li>
<li>Check the <strong>HTTP</strong> option in the <strong>Outputs</strong> frame, note the TCP port 1234 (you can change this if you want to) </li>
<li>Select ASF in the <strong>Encapsulation Method</strong> frame </li>
<li>Check the <strong>Video codec</strong>, select <strong>mp4v</strong>, and <strong>Bitrate</strong> (i used 512 because my DSL upstream is 768) in the <strong>Transcoding options</strong> frame </li>
<li>Check the<strong> Audio codec</strong>, select <strong>mpga</strong>, and <strong>Bitrate</strong> (i used 96 because my DSL upstream is 768) in the <strong>Transcoding options</strong> frame </li>
</ul>
<p>You will want to monkey with the Transcoding options if your client is not VLC, like if its Media Player, or QuickTime (if its QuickTime you may need to change the Encapsulation method to something else, like MP4 (maybe) )</p>
<h3>Firewall Settings</h3>
<ul>
<li>Modify your firewall to allow the TCP port that was selected in VLC (the default is 1234) </li>
</ul>
<h2>The client PC</h2>
<ul>
<li>Start VLC </li>
<li>Click File &#8230; Open Network Stream </li>
<li>Select <strong>HTTP/HTTPS/FTP/MMS</strong> </li>
<li>Type in your source PCs IP address and TCP port in the <strong>URL</strong> textbox (ex: http://mycomputer.dyndns.org:1234) </li>
<li>You may want to add some <strong>Caching</strong> under <strong>Advanced Options</strong>, especially if your Bitrates selected in the Transcoding Options add up to close to your available upstream bandwidth. </li>
</ul>
<h2>Tweaking the Settings</h2>
<h3>If your video is getting jumpy</h3>
<p>Its likely that your stream is too large for your upstream to handle.</p>
<p>It can be useful to watch the <strong>Stream and Media Info</strong> window (on the <u>client</u> VLC) and the <strong>Statistics</strong> tab, to monitor the Input bitrate &#8230; if you see that bitrate stay above your available upstream too often, then adjusting the source bitrate should fix this problem.</p>
<h2>Extra Information</h2>
<ul>
<li><a href="http://www.videolan.org/" rel="nofollow">VideoLAN website</a> - all the documentation for VLC </li>
<li><a href="http://www.doom9.org/" rel="nofollow">Doom9.org</a> - excelent source of transcoding knowledge </li>
<li><a href="http://www.videohelp.com/" rel="nofollow">VideoHelp.com</a> - many many many HOW TO articles on audio/video </li>
</ul>
<p><a type="amzn" asin="B000E1HVDO">Listen to your tunes and movies at work!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2007/09/18/streaming-video-from-home-to-work/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Easy way to kill MS SQL server transaction logs</title>
		<link>http://www.devprise.com/2007/08/19/easy-way-to-kill-ms-sql-server-transaction-logs/</link>
		<comments>http://www.devprise.com/2007/08/19/easy-way-to-kill-ms-sql-server-transaction-logs/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 20:40:32 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.devprise.com/2007/08/19/easy-way-to-kill-ms-sql-server-transaction-logs/</guid>
		<description><![CDATA[I manage many SQL 2000 databases. And many times while performing maintenance I have run into the &#8216;transaction log full&#8217; error.
like this:    Error: 9002, Severity: 17, State: 2     The log file for database &#8216;%.*ls&#8217; is full.
So like many people I resort to using the commands    [...]]]></description>
			<content:encoded><![CDATA[<p>I manage many SQL 2000 databases. And many times while performing maintenance I have run into the &#8216;transaction log full&#8217; error.</p>
<p>like this:    <br />Error: 9002, Severity: 17, State: 2     <br />The log file for database &#8216;%.*ls&#8217; is full.</p>
<p>So like many people I resort to using the commands    <br />BACKUP LOG databasename WITH TRUNCATE_ONLY     <br />DBCC SHRINKFILE</p>
<p>The hassle with this, is that you need to first find out the logical name from sysfiles, or from enterprise manager to be able to use the DBCC SHRINKFILE command</p>
<p>So I wrote a stored procedure that you can install into each of your databases, it will enumerate through the sysfiles table. And perform the above steps against all of the Log files found for the current database. The nice thing is that this works with databases with more than one log file defined.</p>
<div class="csharpcode-wrapper">
<div class="csharpcode">
<pre class="alt"><span class="kwrd">create</span> <span class="kwrd">procedure</span> proc_killLog</pre>
<pre class="alteven">(</pre>
<pre class="alt"> @<span class="kwrd">size</span> <span class="kwrd">int</span> = 2</pre>
<pre class="alteven">)</pre>
<pre class="alt"><span class="kwrd">as</span></pre>
<pre class="alteven"><span class="kwrd">begin</span></pre>
<pre class="alt"> <span class="kwrd">declare</span> @logFile sysname, @db sysname</pre>
<pre class="alteven"> <span class="kwrd">select</span> @db = db_name()</pre>
<pre class="alt"> </pre>
<pre class="alteven"> <span class="kwrd">declare</span> curFiles <span class="kwrd">cursor</span> <span class="kwrd">for</span></pre>
<pre class="alt"> <span class="kwrd">select</span> rtrim([name]) <span class="kwrd">from</span> sysfiles <span class="kwrd">where</span> groupid = 0</pre>
<pre class="alteven"> <span class="kwrd">open</span> curFiles</pre>
<pre class="alt"> <span class="kwrd">fetch</span> <span class="kwrd">next</span> <span class="kwrd">from</span> curFiles</pre>
<pre class="alteven"> <span class="kwrd">into</span> @logFile</pre>
<pre class="alt"> <span class="kwrd">while</span> <span class="preproc">@@FETCH_STATUS</span> = 0</pre>
<pre class="alteven"> <span class="kwrd">begin</span></pre>
<pre class="alt"> <span class="kwrd">BACKUP</span> LOG @db <span class="kwrd">WITH</span> TRUNCATE_ONLY</pre>
<pre class="alteven"> <span class="kwrd">DBCC</span> SHRINKFILE(@logFile, @<span class="kwrd">size</span>)</pre>
<pre class="alt"> <span class="kwrd">fetch</span> <span class="kwrd">next</span> <span class="kwrd">from</span> curFiles</pre>
<pre class="alteven"> <span class="kwrd">into</span> @logFile</pre>
<pre class="alt"> <span class="kwrd">end</span></pre>
<pre class="alteven"> </pre>
<pre class="alt"> <span class="kwrd">close</span> curFiles</pre>
<pre class="alteven"> <span class="kwrd">deallocate</span> curFiles</pre>
<pre class="alt">end</pre>
</p></div>
</div>
<p>This procedure should work with SQL 7, as well as SQL 2005 databases</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devprise.com/2007/08/19/easy-way-to-kill-ms-sql-server-transaction-logs/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
