<?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>Aneef.Net &#187; Tricks &amp; Tips</title>
	<atom:link href="http://www.aneef.net/category/tricks-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aneef.net</link>
	<description>Do it in .Net way &#124; Blogging about C#,ASP.Net, LINQ,WPF and .Net Technologies</description>
	<lastBuildDate>Mon, 24 May 2010 10:50:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fix: .Net 2.0 or 3.5 Setup Project Requires .Net Framework version 4.0</title>
		<link>http://www.aneef.net/2010/05/24/fix-net-2-0-or-3-5-setup-project-requires-net-framework-version-4-0/</link>
		<comments>http://www.aneef.net/2010/05/24/fix-net-2-0-or-3-5-setup-project-requires-net-framework-version-4-0/#comments</comments>
		<pubDate>Mon, 24 May 2010 10:47:57 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[.Net Related]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tricks & Tips]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[.NetFramework4.0]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://www.aneef.net/?p=134</guid>
		<description><![CDATA[Sorry again folks again I was MIA with loads and loads of work. trust me i have more than 30 drafts which i started and never got time to finish. anyway coming to the point this morning i was trying to deploy a windows service project using the setup project templates in visual studio 2010, [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry again folks again I was MIA with loads and loads of work. trust me i have more than 30 drafts which i started and never got time to finish. anyway coming to the point this morning i was trying to deploy a windows service project using the setup project templates in visual studio 2010, and when i tried to install it on client machine i got the following message:</p>
<p><a href="http://www.aneef.net/wp-content/uploads/2010/05/5-24-2010-4-00-44-PM.png"><img class="alignnone size-full wp-image-135" title="5-24-2010 4-00-44 PM" src="http://www.aneef.net/wp-content/uploads/2010/05/5-24-2010-4-00-44-PM.png" alt="The Setup Requires the .Net Framework version 4.0" width="446" height="166" /></a></p>
<p>But I&#8217;m pretty sure that i had the project targeted to .net Framework 3.5 SP1, but still it was  requiring .net 4.0.  as usual i did a Google search and found <a href="http://blogs.iis.net/ma_khan/archive/2009/12/02/troubleshooting-net-2-0-setup-requires-net-4-0-runtime.aspx" target="_blank">this article </a>with the trick to resolve it.</p>
<p>actually it was the dependencies in the setup project causing the issue, it was still targetting 4.0 even though my application targets .net 3.5 and by default VS2010 set the dependency to .Net 4.0.</p>
<p>if you have this issue all you have to do is the following :</p>
<ol>
<li>Double click on the dependencies of the setup project.</li>
<li>Click on the .Net Framework</li>
<li>And you will see the Property window will get enabled.</li>
<li>Change the Version property to your desired .net Framework ( in my case 3.5).</li>
<li>and build your setup again.</li>
</ol>
<p>That&#8217;s it <img src='http://www.aneef.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>for the original article that gave me this solution <a href="http://blogs.iis.net/ma_khan/archive/2009/12/02/troubleshooting-net-2-0-setup-requires-net-4-0-runtime.aspx" target="_blank">visit here</a>.</p>
<p>Just thought i would share this information which that might be helpful for those developers who are in migration process to VS2010 <img src='http://www.aneef.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . hope it help guys!!.</p>
<p>Thanks,</p>
<p>Aneef</p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=134&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2010/05/24/fix-net-2-0-or-3-5-setup-project-requires-net-framework-version-4-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ClickOnce Application,Expired Certificates &amp; Public Key Token PART III &#8211; Pushing .net Framework 3.5</title>
		<link>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/</link>
		<comments>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 11:33:24 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[.Net Related]]></category>
		<category><![CDATA[ClickOnce]]></category>
		<category><![CDATA[Tricks & Tips]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[visual studio 2008]]></category>
		<category><![CDATA[.Net Installation.]]></category>
		<category><![CDATA[Certificate]]></category>
		<category><![CDATA[Check .Net Framework]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/</guid>
		<description><![CDATA[In the last few weeks I wrote 2 articles on how to resolve ClickOnce certificate expiration issues. you can find those articles here : ClickOnce Application,Expired Certificates &#38; Public Key Token PART I ClickOnce Application,Expired Certificates &#38; Public Key Token PART II During my work on this ClickOnce update, we decided to upgrade the application [...]]]></description>
			<content:encoded><![CDATA[<p>In the last few weeks I wrote 2 articles on how to resolve ClickOnce certificate expiration issues. you can find those articles here :</p>
<ol>
<li><a href="http://www.aneef.net/2009/06/11/clickonce-applicationexpired-certificates-public-key-token-part-i/">ClickOnce Application,Expired Certificates &amp; Public Key Token PART I</a>
<li><a href="http://www.aneef.net/2009/06/11/clickonce-applicationexpired-certificates-public-key-token-part-ii/">ClickOnce Application,Expired Certificates &amp; Public Key Token PART II</a> </li>
</ol>
<ol>During my work on this ClickOnce update, we decided to upgrade the application to target .net framework 3.5 sp1.</ol>
<ol>so I just set the target framework to 3.5 and set the required prerequisites (.net 3.5 SP1, and Windows Installer 3.1). and built the project and published it. and when I tried on a client machine which had .net framework 2.0, application got updated, prompted the uninstall message, and tried to launch the new ClickOnce application from the new URL, and BANG!. we get an error :</ol>
<ol><a href="http://www.aneef.net/wp-content/uploads/2009/07/image001.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image001" src="http://www.aneef.net/wp-content/uploads/2009/07/image001_thumb.jpg" width="286" height="142"></a></ol>
<ol>The Error Message Says :</ol>
<blockquote><p>Unable to install or run the application. The application</p>
<p>requires that assembly WindowsBase Version 3.0.0.0 be</p>
<p>installed in the Global Assembly Cache (GAC) first.</p>
</blockquote>
<p>Why is this ?, its because when we try to launch the new application URL we do this :</p>
<pre>DeploymentUtils.AutoInstall("&lt;Path toNewApplication.application&gt;");</pre>
<pre>&nbsp;</pre>
<p>we request for the application manifest. and it fails to launch the application because it doesn&#8217;t have the prerequisites. and now to force the new prerequisites the application should call the setup.exe in the Web Server instead of the manifest. now the question is, what if the user already have&nbsp; the .net Framework 3.5 SP1?, we don&#8217;t have to prompt the client to install them again by launching setup.exe, we just have to launch the manifest. To Serve both the above scenario we need to check if the client machine has .net framework 3.5 SP1, and depending on its availability we need to launch the manifest or the setup.exe. The existence of .net Framework can be obtained from the following registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP <a href="http://www.aneef.net/wp-content/uploads/2009/07/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.aneef.net/wp-content/uploads/2009/07/image_thumb.png" width="544" height="216"></a> you can find out all the .net Frameworks installed and their service pack versions in this registry entry. Following are the locations of the main Net Frameworks:</p>
<table border="0" cellspacing="0" cellpadding="2" width="540">
<tbody>
<tr>
<td valign="top" width="128">Framework 1.1</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v1.1.4322</td>
</tr>
<tr>
<td valign="top" width="128">Framework 2.0</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727</td>
</tr>
<tr>
<td valign="top" width="128">Framework 3.0</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v3.0\\Setup</td>
</tr>
<tr>
<td valign="top" width="128">Framework 3.5</td>
<td valign="top" width="411">Software\\Microsoft\\NET Framework Setup\\NDP\\v3.5</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Now we can check if the required .net Framework is available in the client machine, and launch the application setup.exe or the manifest. to do this we need to programmatically check these registries. for this I used the attached code ( I Couldn&#8217;t find the original author, Credits goes to him/her) which I found from web and modified to avoid few bugs. you can add this code to your project and do the below check in your application to decide which file to be launched :</p>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode"><span class="kwrd">string</span> FileToLaunch=<span class="str">@"/setup.exe"</span>;
<span class="kwrd">if</span> (FrameworkUtils.IsInstalled(FrameworkVersion.Fx35)

 &amp;&amp; FrameworkUtils.GetServicePackLevel(FrameworkVersion.Fx35) == 1)
          {
            FileToLaunch = <span class="str">@"/&lt;application manifest.application&gt;"</span>;
          }
            MessageBox.Show(<span class="str">"Your message here"</span>);
            <span class="kwrd">string</span> updateURL = DeploymentUtils.getUpdateURL();
            DeploymentUtils.UninstallMe();
            DeploymentUtils.AutoInstall(<span class="str">"https://"</span> + updateURL + FileToLaunch);
            Application.Exit();</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<pre class="csharpcode">&nbsp;</pre>
<p>And that&#8217;s all, now the application will launch the setup.exe if the client doesn&#8217;t have the .net Framework 3.5 and prompt for its installation, or launch the application manifest if client has the framework installed.</p>
<p>Now you can solve your ClickOnce issue as well as upgrade .net Framework in client machine at the same time without problem.</p>
<p><a href="wp-content/uploads/2009/07/FrameworkUtil.cs.txt">Download FrameworkUtils.cs</a></p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=97&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/07/09/clickonce-applicationexpired-certificates-public-key-token-part-iii-pushing-net-framework-3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net 3.5  ListView Control and Book Flip effect</title>
		<link>http://www.aneef.net/2009/04/16/aspnet-35-listview-control-and-book-flip-effect/</link>
		<comments>http://www.aneef.net/2009/04/16/aspnet-35-listview-control-and-book-flip-effect/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 08:28:54 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Tricks & Tips]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/04/16/aspnet-35-listview-control-and-book-flip-effect/</guid>
		<description><![CDATA[one of the coolest control in ASP.Net 3.5 is its Listview Control. its too CSS friendly, and we can use it to achieve many great content presentations. if you go to scottgu&#8217;s blog you can find some good articles on how to use the listview control. recently I did such an implementation. its using the [...]]]></description>
			<content:encoded><![CDATA[<p>one of the coolest control in ASP.Net 3.5 is its <a href="http://msdn.microsoft.com/en-us/library/bb398790.aspx" target="_blank">Listview</a> Control. its too CSS friendly, and we can use it to achieve many great content presentations. if you go to scottgu&#8217;s blog you can find some good articles on <a href="http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx" target="_blank">how to use the listview control</a>. </p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:84c1fa9b-1ab9-4cb7-bd88-7865eb5324e1" class="wlWriterSmartContent">
<div id="120aa13c-244b-4179-b933-42a7c1ab72ae" style="margin: 0px; padding: 0px; display: inline;">
<div><a href="http://www.youtube.com/watch?v=nNnk9chiriU" target="_new"><img src="http://www.aneef.net/wp-content/uploads/2009/04/video83c3c0ada8e7.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('120aa13c-244b-4179-b933-42a7c1ab72ae'); downlevelDiv.innerHTML = &quot;&lt;div&gt;&lt;object width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;param name=\&quot;movie\&quot; value=\&quot;http://www.youtube.com/v/nNnk9chiriU\&quot;&gt;&lt;\/param&gt;&lt;param name=\&quot;wmode\&quot; value=\&quot;transparent\&quot;&gt;&lt;\/param&gt;&lt;embed src=\&quot;http://www.youtube.com/v/nNnk9chiriU\&quot; type=\&quot;application/x-shockwave-flash\&quot; wmode=\&quot;transparent\&quot; width=\&quot;425\&quot; height=\&quot;355\&quot;&gt;&lt;\/embed&gt;&lt;\/object&gt;&lt;\/div&gt;&quot;;" alt=""></a></div>
</div>
</div>
<p>recently I did such an implementation. its using the <a href="http://www.coastworx.com/bookflip.php" target="_blank">javascript bookflip.</a> a great work by <a href="http://coastworx.com/contact.php" target="_blank">Will</a> (very kind of him to share this to the world). I used the his code, and ListView to achieve a dynamic bookflip.&nbsp; apart from the javascript changes,&nbsp; here is the change I did for the Listview markup.</p>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode">&nbsp;</pre>
<pre class="csharpcode"> <span class="kwrd">&lt;</span><span class="html">asp:ListView</span> <span class="attr">id</span><span class="kwrd">="ImageFlip"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">ItemPlaceholderID</span><span class="kwrd">="ItemContainer"</span><span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;</span><span class="html">LayoutTemplate</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">id</span><span class="kwrd">="myBook"</span> <span class="attr">style</span><span class="kwrd">="width: &lt;%# flipWidth*2 %&gt;px; height:</span></pre>
<pre class="csharpcode"><span class="kwrd"> &lt;%# flipHeight %&gt;px; position: relative; z-index: 5;"</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:PlaceHolder</span> <span class="attr">ID</span><span class="kwrd">="ItemContainer"</span>  <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">style</span><span class="kwrd">="border: 0px solid #ddd;
    text-align: center;
    padding-top: 100px;
    margin: 0px;
    height: 0px;
    text-align:inherit;
    background-color: #ffffff;
 color: #cf0000;vertical-align:bottom"</span> <span class="attr">Name</span><span class="kwrd">="Back"</span> <span class="kwrd">&gt;</span> </pre>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">img</span> <span class="attr">src</span><span class="kwrd">="spongebob300/bk.jpg"</span>  <span class="attr">border</span><span class="kwrd">="0"</span> <span class="attr">usemap</span><span class="kwrd">="#Map"</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>

      <span class="kwrd">&lt;/</span><span class="html">div</span> <span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;/</span><span class="html">LayoutTemplate</span><span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>

   <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">style</span><span class="kwrd">="background:#ffffff ;color:#ffffff;</span></pre>
<pre class="csharpcode"><span class="kwrd"> cursor:url(ajax/zoom-in.cur),auto; z-index:-&lt;%#Eval("</span><span class="attr">PAGENO</span><span class="kwrd">") %&gt;;"</span> </pre>
<pre class="csharpcode"><span class="attr">name</span><span class="kwrd">="Page &lt;%#Eval("</span><span class="attr">PAGENO</span><span class="kwrd">") %&gt;"</span> <span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">="Javascript:getFullImage(&lt;%#Eval("</span><span class="attr">ID</span><span class="kwrd">") %&gt;)"</span> <span class="kwrd">&gt;</span></pre>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">img</span> <span class="attr">src</span><span class="kwrd">="&lt;%#Eval("</span><span class="attr">FlipImage</span><span class="kwrd">") %&gt;"</span> <span class="attr">alt</span><span class="kwrd">="Page &lt;%#Eval("</span><span class="attr">PAGENO</span><span class="kwrd">") %&gt;"</span> </pre>
<pre class="csharpcode">  <span class="attr">border</span><span class="kwrd">="0"</span> <span class="attr">style</span><span class="kwrd">="cursor:url(ajax/zoom-in.cur),auto;"</span> <span class="kwrd">/&gt;&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span>
   <span class="kwrd">&lt;/</span><span class="html">asp:ListView</span><span class="kwrd">&gt;</span>
</pre>
<pre class="csharpcode">&nbsp;</pre>
<p>And the Data Retrieval is just as simple as the following 3 lines:</p>
<div class="csharpcode">
<pre class="alt">DataTable dt = db.getFlipPage(catid);</pre>
<pre>ImageFlip.DataSource = dt;</pre>
<pre class="alt">ImageFlip.DataBind();</pre>
</div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>&nbsp;</p>
<p>And that&#8217;s all. very easy isn&#8217;t it. for the real implementation of this go to <a href="http://www.catalogues4u.com.au">www.catalogues4u.com.au</a> and click on a catalogue.In that site I have also implemented a carousel using Listview.&nbsp; hope it helps.</p>
<pre class="csharpcode">&nbsp;</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p><br/><br />
<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.aneef.net%2f2009%2f04%2f16%2faspnet-35-listview-control-and-book-flip-effect%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.aneef.net%2f2009%2f04%2f16%2faspnet-35-listview-control-and-book-flip-effect%2f" border="0" alt="kick it on DotNetKicks.com" /></a><br />
<br/><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3530459083226419";
/* linksonly */
google_ad_slot = "6143752371";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br/><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3530459083226419";
//468x60, created 12/20/07
google_ad_slot = "4319330936";
google_ad_width = 468;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=56&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/04/16/aspnet-35-listview-control-and-book-flip-effect/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>100 % CPU SQL Server 2005, Server crashes!</title>
		<link>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/</link>
		<comments>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 14:54:27 +0000</pubDate>
		<dc:creator>Aneef Fashir</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tricks & Tips]]></category>

		<guid isPermaLink="false">http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/</guid>
		<description><![CDATA[Ah back to my blog. well these days I’m on holidays for Sinhala/ Tamil New year in Sri Lanka. so anyway let met start with wishing all Sinhala  and Tamil Friends A HAPPY NEW YEAR. Lets get back to business, its been a long time since my last post, as usual busy schedules (i know, [...]]]></description>
			<content:encoded><![CDATA[<p>Ah back to my blog. well these days I’m on holidays for Sinhala/ Tamil New year in Sri Lanka. so anyway let met start with wishing all Sinhala  and Tamil Friends A HAPPY NEW YEAR.</p>
<p>Lets get back to business, its been a long time since my last post, as usual busy schedules (i know, i know i tell this often !), but all these days i had several bits and pieces on queue for my blog, and here i am with that.</p>
<p>Last week i had an early morning call from Administrators of  <a href="http://www.catalogues4u.com.au/">Catalogues4u.com.au</a>. they said that the website is running very slow, and users are having connection timeouts in their browsers or poor performance, server logs are filled with SQLConnection Timeout. they have been receiving calls, complaints from their top management, and most of all server restarts. horrible isn’t it?  they have checked the server, and the CPU was running almost 100%, and the culprit which used the most of the CPU was SQL Server.</p>
<p>After spending time in logs, and SQL profiler runs, i found that one stored procedure was taking more time to execute than the others.</p>
<p>here is a part of that SP:</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span>  <span class="kwrd">DISTINCT</span> c.ENDDATE,c.ID, c.NAME,c.THUMBNAILURL,c.CONTENSDESCRIPTION
<span class="kwrd">INTO</span> #temp
<span class="kwrd">FROM</span> GW_CATELOGUE c
 <span class="kwrd">INNER</span> <span class="kwrd">JOIN</span> dbo.GW_CATELOGUE_POSTCODES cp
  <span class="kwrd">ON</span> c.ID=cp.CATELOGUEID
 <span class="kwrd">INNER</span> <span class="kwrd">JOIN</span> dbo.GW_POSTCODES p <span class="kwrd">ON</span> p.Id=cp.POSTCODEID
<span class="kwrd">WHERE</span>  p.POSTCODE=@postcode
 <span class="kwrd">AND</span> (ENDDATE <span class="kwrd">BETWEEN</span> getDate() <span class="kwrd">AND</span> DATEADD(dd, 7, getDate()))
 <span class="kwrd">AND</span> (STARTDATE &lt;= getDate())
 <span class="kwrd">AND</span> (ENDDATE &gt;= getDate())
 <span class="kwrd">AND</span> c.APPROVED=1 <span class="kwrd">ORDER</span> <span class="kwrd">BY</span> c.ENDDATE</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>There were some other SP’s with same structure except the  below Date Filtering which were running perfectly alright:</p>
<pre class="csharpcode"><span class="kwrd">AND</span> (ENDDATE <span class="kwrd">BETWEEN</span> getDate() <span class="kwrd">AND</span> DATEADD(dd, 7, getDate()))</pre>
<pre class="csharpcode"><span class="kwrd">AND</span> (STARTDATE &lt;= getDate()) <span class="kwrd">AND</span> (ENDDATE &gt;= getDate())</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Well This made me thing something is fishy with the date. with confused mind, and help of MVP <a href="http://dineshpriyankara.spaces.live.com/">Dinesh Priyangara</a> I Created 4 <a href="http://www.sql-server-performance.com/articles/per/index_data_structures_p1.aspx">Non- Clustered Indexes</a> on Catalogue_STARTDATE, Catalogue_ENDDATE and POSTCODE:</p>
<pre class="csharpcode"><span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> Catalogue_STARTDATE <span class="kwrd">ON</span> GW_CATELOGUE(STARTDATE)
<span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> Catalogue_ENDDATE <span class="kwrd">ON</span> GW_CATELOGUE(ENDDATE)
<span class="kwrd">CREATE</span> <span class="kwrd">INDEX</span> PostCodes_POSTCODE <span class="kwrd">ON</span> GW_POSTCODES(POSTCODE)</pre>
<pre class="csharpcode"></pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>And Bang!! it worked. server  was back to normal, and everyone was happy. well this might not be a big deal, but still as somebody said, information is wealth!!.</p>
<p><br/><br />
<!--adsense#links--> <br/><br />
<!--adsense#inpost--></p>
<img src="http://www.aneef.net/?ak_action=api_record_view&id=50&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.aneef.net/2009/04/11/100-cpu-sql-server-2005-servers-crashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
