<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Simon Deshaies .Net Development Weblog</title>
    <description />
    <link>http://weblog.simondeshaies.net/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.NET 1.5.0.7</generator>
    <language>en-US</language>
    <blogChannel:blogRoll>http://weblog.simondeshaies.net/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://weblog.simondeshaies.net/syndication.axd</blogChannel:blink>
    <dc:creator>Simon Deshaies</dc:creator>
    <dc:title>Simon Deshaies .Net Development Weblog</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/SimonDeshaies" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
      <title>Where did my .Net 3.5 generic extension go?</title>
      <description>&lt;p&gt;There are those things in programming that if you just don't know. Well that you got to know. Where are your extension methods is one of those things.&lt;/p&gt;  &lt;p&gt;Microsoft decided to put a bunch of extensions for string in System.Linq. Yeah, no big deal. Could you have guessed? Well it happens that if you don’t specify the namespace for a extension method you will not get any type of suggestion in intellisene as you get with regular methods. And that’s because the reflection will just never find it.&lt;/p&gt; [] &lt;p&gt;So this code would give you the error below if the “using System.Linq” was absent.&lt;/p&gt;  &lt;p&gt;Code:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;using System.Linq;

public class Class1
{
    void main()
    {
        string[] arr = new string[5];
        arr.Contains&amp;lt;string&amp;gt;(&amp;quot;where is my extention&amp;quot;);
    }
}&lt;/pre&gt;

&lt;p&gt;Error:&lt;/p&gt;

&lt;pre class="brush: xml;"&gt;Error    1    'System.Array' does not contain a definition for 'Contains'
and no extension method 'Contains' accepting a first argument of type 'System.Array' could be found
(are you missing a using directive or an assembly reference?)    
c:\users\documents\visual studio 2010\Projects\ClassLibrary1\ClassLibrary1\Class1.cs    8    13    ClassLibrary1&lt;/pre&gt;

&lt;p&gt;This is not bad it’s just 1 men day down the drain.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/fIF72PnEs2U" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/fIF72PnEs2U/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2009/11/04/Where-did-my-Net-35-generic-extension-go.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=301bffef-4529-406d-aae8-d2e935aa2470</guid>
      <pubDate>Wed, 04 Nov 2009 16:34:39 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=301bffef-4529-406d-aae8-d2e935aa2470</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=301bffef-4529-406d-aae8-d2e935aa2470</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2009/11/04/Where-did-my-Net-35-generic-extension-go.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=301bffef-4529-406d-aae8-d2e935aa2470</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=301bffef-4529-406d-aae8-d2e935aa2470</feedburner:origLink></item>
    <item>
      <title>Disk Partition Alignment for SQL Server as Storage Best Practice</title>
      <description>&lt;p&gt;Some times we have this huge server, dedicated to SQL Server. It processes thousands or even millions of transactions a day. It should keep up because we really did buy the works, the hard drive and memory such load requires. And yet, it does not deliver what you paid for.&lt;/p&gt;  &lt;p&gt;Well some people got curious. Not just me, but, including me. Here is a aggregation of these finding.&lt;/p&gt;  &lt;p&gt;If basic partition(s) or dynamic volume(s) are created on a disk that is not track aligned, an I/O operation may cross, or straddle, disk track boundaries. If an I/O operation does straddle a track boundary, it can consume extra resources or cause additional work in the storage array, leading to performance loss.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;What does this mean?&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;The fact is that under windows the MBR (Master Boot Record) takes up the first 63 sectors. So the first track starts one sector to early at the 64th sector which misaligns it with the underlying physical disk and results in serious performance degradation.&lt;/p&gt;  &lt;p&gt;Properly aligning the partition on a disk or disk array is a fundamental best practice. Moreover this can have a great impact on a SQL Server. Since SQL Server is a fine tuned system the misaligned partition can cause slowdown up to 90%.&lt;/p&gt;  &lt;p&gt;Correctly aligning partitions in your environment could, and most frequently, will cause performance increase from 10% to 30%. And it has even been experience improvement up to 50% on the read, write in the SQL database.&lt;/p&gt;  &lt;h3&gt;Disk Partition Alignment for SQL Server&lt;/h3&gt;  &lt;p&gt;The most important data structure on the disk is the Master Boot Record (MBR), which resides on the first sector of the disk. MBR contains the boot-loader and partition table. The partition table maintains starting and ending sector values, which in Windows are only 6 bits in length. Therefore, their maximum value is 63 due to this limited number of bits and the fact that sector enumeration begins at 1, not 0. Also, it may be easier to think of a disk as a sequence of blocks (rather than sectors) starting from address zero and incrementing until the end of the disk. Note that block enumeration begins at 0, not 1.&lt;/p&gt;  &lt;p&gt;Windows creates partitions on cylinder boundaries and, by default, allocates the first 63 sectors as hidden sectors. With a physical disk that maintains 64 sectors per track, Windows always creates the partition starting at the 64th sector (block address 63), which misaligns it with the underlying physical disk and results in serious performance degradation. If we use the Windows default partition location (63), an I/O of 4,096 bytes (8 sectors/blocks) starting at the beginning of the partition will write one block to the last block of the first track and seven blocks to the start of the second track. This means the I/O will straddle the first and second tracks. This will require the storage array to reserve two cache slots for the data and will also require two flush I/O operations to the disk, which will impact the performance.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblog.simondeshaies.net/image.axd?picture=DiskPartitionAlignmentSqlServer1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DiskPartitionAlignmentSqlServer1" border="0" alt="DiskPartitionAlignmentSqlServer1" src="http://weblog.simondeshaies.net/image.axd?picture=DiskPartitionAlignmentSqlServer1_thumb.png" width="670" height="225" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For illustration purposes, in Figure 2 the partition is broken into 4-KB blocks and arranged in sequence with two different colors. It clearly shows that one of every 8 blocks would straddle a track boundary.&lt;/p&gt;  &lt;p&gt;Suppose a partition is created along the track boundary of the underlying disk. The partition layout in the physical disk would be as depicted in Figure 3. In this case, there are no 4-KB blocks straddling a track boundary.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblog.simondeshaies.net/image.axd?picture=DiskPartitionAlignmentSqlServer2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DiskPartitionAlignmentSqlServer2" border="0" alt="DiskPartitionAlignmentSqlServer2" src="http://weblog.simondeshaies.net/image.axd?picture=DiskPartitionAlignmentSqlServer2_thumb.png" width="670" height="225" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;According to performance analysis information, I/O to a misaligned partition in a storage area network (SAN) with 64 sectors per track would result in the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Any I/O of 32 KB or larger will always cause a boundary crossing. &lt;/li&gt;    &lt;li&gt;Any random I/O of 16 KB will cause a boundary crossing 50 percent of the time. &lt;/li&gt;    &lt;li&gt;Any random I/O of 8 KB will cause a boundary crossing 25 percent of the time. &lt;/li&gt;    &lt;li&gt;Any random I/O of 4 KB will cause a boundary crossing 12.5 percent of the time. &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Results&lt;/h3&gt;  &lt;p&gt;How much do you get out of this? In Jimmy May presentation he talks of results such as:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Hitachi High-End SANs 8% – 12% &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Financial Firm: 40% faster ETL, Re-built Multi-TB SharePoint Backend&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Telecom Firm: Maintenance: 4 hours &amp;gt;&amp;gt; 90 minutes&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;1M Row Insert into 140M Row table: 6:59 &amp;gt;&amp;gt; 0:52&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;1M Row Insert into 500M Row table: 40% faster &lt;/li&gt;        &lt;li&gt;Re-built Dozens of TBs of Data &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;From the information I gathered the average increase in performance for SQL Server is from 10% to 30%.&lt;/p&gt;  &lt;h3&gt;Verify if disk are align&lt;/h3&gt;  &lt;p&gt;There are many ways to do so here I provide one of them. Microsoft offers a &lt;a href="http://support.microsoft.com/kb/929491"&gt;how to on their support network&lt;/a&gt;. More details on this can also be found in the attach PDF.&lt;/p&gt;  &lt;p&gt;To get the starting offset of your partition you perform the below command in your command prompt.&lt;/p&gt;  &lt;pre&gt;C:\&amp;gt;wmic partition get BlockSize, StartingOffset, Name, Index
BlockSize  Index  Name                   StartingOffset
512        0      Disk #0, Partition #0  1048576
512        1      Disk #0, Partition #1  42950721536
512        2      Disk #0, Partition #2  53688139776&lt;/pre&gt;

&lt;p&gt;Knowing the my disk index 0 is my partition c:&lt;/p&gt;

&lt;pre&gt;C:\&amp;gt;fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number :       0x0af22bc1f22bafbd
Version :                         3.1
Number Sectors :                  0x0000000004ffffff
Total Clusters :                  0x00000000009fffff
Free Clusters  :                  0x00000000002e8986
Total Reserved :                  0x00000000000007f0
Bytes Per Sector  :               512
Bytes Per Cluster :               4096
Bytes Per FileRecord Segment    : 1024
Clusters Per FileRecord Segment : 0
Mft Valid Data Length :           0x00000000097d0000
Mft Start Lcn  :                  0x00000000000c0000
Mft2 Start Lcn :                  0x00000000004fffff
Mft Zone Start :                  0x0000000000793620
Mft Zone End   :                  0x000000000079fe40
RM Identifier:        CBD70D39-B4C5-11DD-B78E-806E6F6E6963&lt;/pre&gt;

&lt;p&gt;I will make 2 calculation from them, If my partition are align the result of both will be integer. If you get decimals your disks are definitely not align. 
  &lt;br /&gt;&lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="2" width="353"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="112"&gt;StartingOffset &lt;/td&gt;

      &lt;td valign="top" width="12"&gt;&amp;#160;&lt;/td&gt;

      &lt;td valign="top" width="209"&gt;Bytes Per Cluster&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="112"&gt;1048576 &lt;/td&gt;

      &lt;td valign="top" width="12"&gt;÷&lt;/td&gt;

      &lt;td valign="top" width="209"&gt;4096 &lt;/td&gt;

      &lt;td valign="top" width="10"&gt;=&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;256&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="112"&gt;Bytes Per Cluster&lt;/td&gt;

      &lt;td valign="top" width="12"&gt;&amp;#160;&lt;/td&gt;

      &lt;td valign="top" width="209"&gt;Bytes Per FileRecord Segment&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="112"&gt;4096 &lt;/td&gt;

      &lt;td valign="top" width="12"&gt;÷&lt;/td&gt;

      &lt;td valign="top" width="209"&gt;1024 &lt;/td&gt;

      &lt;td valign="top" width="10"&gt;=&lt;/td&gt;

      &lt;td valign="top" width="10"&gt;4&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;Performing Disk Alignment&lt;/h3&gt;

&lt;p&gt;With a physical disk that maintains 64 sectors per track, Windows always creates the partition starting at the sixty-forth sector, therefore misaligning it with the underlying physical disk. To be certain of disk alignment, use Diskpart.exe, a disk partition tool. Diskpart.exe is a utility provided by Microsoft in the Windows Server 2003 Service Pack 1 Support Tools that can explicitly set the starting offset of the master boot record (MBR). By setting the starting offset, you can track alignment and improve disk performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before You Begin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Diskpart is a data destructive utility. When used against a disk, all data on the disk will be wiped out during the storage track boundary alignment process. Therefore, if the disk on which you will run Diskpart contains data, backup the disk before performing the following procedure.&lt;/p&gt;

&lt;hr /&gt;Note: Diskpart can only be used with basic disks. Diskpart cannot be used with dynamic disks. Diskpart supersedes the functionality previously found in Diskpar.exe. Diskpar and Diskpart should only be used if the drive is translated as 64 sectors per track. 

&lt;hr /&gt;

&lt;p&gt;Diskpart.exe is located in the following directory by default on systems running Windows Server 2003 : C:\WINDOWS\system32&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To align Exchange I/O with storage track boundaries using Diskpart.exe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the disk you are aligning is already blank (raw), proceed to Step 3. If the disk contains data, backup the disk before proceeding.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Delete all partitions on the disk. &lt;/li&gt;

  &lt;li&gt;Open a command prompt, and execute Diskpart.exe. &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;At the Diskpart command prompt, type &lt;strong&gt;List Disk&lt;/strong&gt; and press Enter. If the disk you want to align does not appear in the list make sure that it exists and is accessible using the Disk Management snap-in.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;At the Diskpart command prompt, type &lt;strong&gt;Select Disk&lt;/strong&gt; &lt;em&gt;X&lt;/em&gt;, where &lt;em&gt;X&lt;/em&gt; is the number of the disk as shown in the output of the &lt;strong&gt;List Disk&lt;/strong&gt; command. Diskpart should return a message that indicates that Disk &lt;em&gt;X&lt;/em&gt; is the selected disk.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;At the Diskpart command prompt, type &lt;strong&gt;Create Partition Primary Align&lt;/strong&gt;&lt;em&gt;=X&lt;/em&gt;, where &lt;em&gt;X&lt;/em&gt; is either 32 or 64, depending on the recommendation from your storage vendor. If your storage vendor does not have any specific recommendations, it is recommended that you use 64.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;At the Diskpart command prompt, type &lt;strong&gt;Assign Letter&lt;/strong&gt;&lt;em&gt;=&amp;lt;DriveLetter&amp;gt;&lt;/em&gt;. For example, to assign letter Z to the disk, type &lt;strong&gt;Assign Letter=Z.&lt;/strong&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;Once the drive letter is assigned, type &lt;strong&gt;exit&lt;/strong&gt; to exit out of the Diskpart utility.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;Use the Disk Management snap-in or the Windows Format command to format the partition as an NTFS-formatted partition. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/929491" target="_blank"&gt;Microsoft Support: Predeployment I/O Best Practices SQL Server Best Practices Article&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/300415" target="_blank"&gt;Microsoft Support: A Description of the Diskpart Command-Line Utility&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/aa995867(EXCHG.65).aspx" target="_blank"&gt;Microsoft TechNet: How to Align Exchange I/O with Storage Track Boundaries&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/pdpliobp.mspx" target="_blank"&gt;Microsoft TechNet: Disk performance may be slower than expected when you use multiple disks in Windows Server 2003, in Windows XP, and in Windows 2000&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://blogs.msdn.com/jimmymay/archive/2008/10/14/disk-partition-alignment-for-sql-server-slide-deck.aspx" target="_blank"&gt;Disk Partition Alignment (Sector Alignment) for SQL Server: Part 1: Slide Deck&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://blogs.msdn.com/jimmymay/archive/2008/11/04/disk-partition-alignment-sector-alignment-for-sql-server-part-2-adding-hp-eva-8000-to-veritas-enterprise-administrator-track-alignment-settings-dialog.aspx" target="_blank"&gt;Disk Partition Alignment (Sector Alignment) for SQL Server: Part 2: Adding HP EVA 8000 to Veritas Enterprise Administrator “Track Alignment Settings” Dialog&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://weblog.simondeshaies.net/sample/DiskPartitionAlignmentforSQLServerJimmyMayv.20081016.pdf" target="_blank"&gt;Disk Partition Alignment for SQL Server by Jimmy May&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&lt;a href="http://weblog.simondeshaies.net/sample/ent-whitepaper_vsfw_5.0_best_practices_for_storage_mgmt_02-2007.en-us.pdf" target="_blank"&gt;Symantec Veritas Storage Foundation™ 5.0 for Windows Best Practices for Storage Management&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/GZ5jCzk2hP4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/GZ5jCzk2hP4/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2009/03/28/Disk-Partition-Alignment-for-SQL-Server-and-as-Storage-Best-Practice.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=b07d8f35-a132-4b30-972e-73d152ebd0e1</guid>
      <pubDate>Sat, 28 Mar 2009 04:11:30 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=b07d8f35-a132-4b30-972e-73d152ebd0e1</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=b07d8f35-a132-4b30-972e-73d152ebd0e1</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2009/03/28/Disk-Partition-Alignment-for-SQL-Server-and-as-Storage-Best-Practice.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=b07d8f35-a132-4b30-972e-73d152ebd0e1</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=b07d8f35-a132-4b30-972e-73d152ebd0e1</feedburner:origLink></item>
    <item>
      <title>Passing Value From ASPX Page to Code Behind</title>
      <description>&lt;p&gt;Passing&amp;#160; value from a aspx form to code behind is a challenge the APS.NET developer faces often. I my self found very creative ways to do so over the years. One of my favored for a log time was to use the OnClientClick event to set a hidden value field before the form was submitted to the server.&lt;/p&gt;  &lt;p&gt;Yesterday I started to use User Controls and I could not have the JavaScript function in each control, and certainly not refer to the parent. I would of just broke the reusability of the control. That's when I discovered this quite cool property of the Button and LinkButton. It was certainly not meant to be use in this way but it's much more elegant then the HiddenField one. &lt;/p&gt; []  &lt;p&gt;Instead of using the OnClientClick event I set the value of the CommandArgument property when rendering the page as follows:&lt;/p&gt;  &lt;p&gt;ListView Item:&lt;/p&gt;  &lt;pre class="brush: xml;"&gt;&amp;lt;asp:LinkButton runat=&amp;quot;server&amp;quot;
 Text='&amp;lt;%# Eval(&amp;quot;SomeName&amp;quot;) %&amp;gt;' 
 CommandArgument='&amp;lt;%# Eval(&amp;quot;SomeId&amp;quot;) %&amp;gt;' 
 OnClick=&amp;quot;Delete&amp;quot; ID=&amp;quot;DeleteLinkButton&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;So when the server receives the form your button event is triggered:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;protected void Delete(object sender, EventArgs e)
{
    Object Obj = ((LinkButton)sender).CommandArgument;
    //Do something with Obj;
}&lt;/pre&gt;

&lt;p&gt;So here it is 2 steps to get the value from the LinkButton. In the Delete method I cast the sender to LinkButton so I can access the CommandArgument property.&lt;/p&gt;

&lt;p&gt;Let me know what you think.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/h8LGMEGrqB8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/h8LGMEGrqB8/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2009/01/12/Passing-Value-From-ASPX-Page-to-Code-Behind-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=9d57d2c5-be36-496f-a55d-bf51b945fdc4</guid>
      <pubDate>Mon, 12 Jan 2009 15:07:43 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=9d57d2c5-be36-496f-a55d-bf51b945fdc4</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=9d57d2c5-be36-496f-a55d-bf51b945fdc4</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2009/01/12/Passing-Value-From-ASPX-Page-to-Code-Behind-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=9d57d2c5-be36-496f-a55d-bf51b945fdc4</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=9d57d2c5-be36-496f-a55d-bf51b945fdc4</feedburner:origLink></item>
    <item>
      <title>My Blog Changes</title>
      <description>&lt;p&gt;Yesterday I migrated my blog to a new server. In the process I decided it would be nice to upgrade to the new version (1.4.5). So I discovered a couple of things.&lt;/p&gt; &lt;p&gt;BlogEngine.Net does not support SQL Server 2000, yeah I now&amp;nbsp; it's a old version of SQL but this new server has it. Why? Well I try to keep all my stuff licensed when this server was setup SQL 2000 seemed like the right thing since the 2000 license are much less expensive. The down side is that nvarchar (max) is not supported, so you need to use NText, which was fine until many other statement are not supported either.&lt;/p&gt; &lt;p&gt;Then the right thing seemed to go back to XmlDataSource. Al Nyveldt offered a &lt;a target="_blank" href="http://www.nyveldt.com/blog/page/BlogEngineNET-Provider-Migration.aspx"&gt;BlogEngine.NET Provider Migration&lt;/a&gt;. I needed to bend it a couple of way to use the new version to make it happen but I succeeded. So now I'm fully XML!&lt;/p&gt; &lt;p&gt;I had this blog for about a year now and I thought it was also time to change the style a bit. My good old Standard theme did seemed a bit doll after this time. So Today I embarked on the quest to change the palette. Mads Kristensen does pretty good job creating themes, which made my quest an easy job. I'm pretty happy with the result. For those that do not remember what it used to look like here's the screen shot:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://weblog.simondeshaies.net/image.axd?picture=WindowsLiveWriter/MyBlogChangesSimonDeshaies_A7DD/image_5.png" width="704" height="369"&gt; &lt;/p&gt; &lt;p&gt;Let me know what you think of this new style. I appreciate the comments.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/6oXjAQ1gdhM" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/6oXjAQ1gdhM/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2009/01/10/My-Blog-Changes-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=88086c21-b6fb-4d71-b707-bbb7b37f0c8f</guid>
      <pubDate>Sat, 10 Jan 2009 06:56:53 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=88086c21-b6fb-4d71-b707-bbb7b37f0c8f</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=88086c21-b6fb-4d71-b707-bbb7b37f0c8f</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2009/01/10/My-Blog-Changes-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=88086c21-b6fb-4d71-b707-bbb7b37f0c8f</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=88086c21-b6fb-4d71-b707-bbb7b37f0c8f</feedburner:origLink></item>
    <item>
      <title>Vote for OpenX!</title>
      <description>&lt;p&gt;
OpenX is nominated to &lt;a href="http://crunchies2008.techcrunch.com/" target="_blank"&gt;The Crunchies 2008 Awards&lt;/a&gt;. &lt;a href="http://weblog.simondeshaies.net/post/2008/09/OpenX-Ad-Management-Software-7c-Simon-Deshaies.aspx" target="_blank"&gt;As I blog earlier&lt;/a&gt; OpenX is one of the most interesting open source application I discovered in 2008. And they have a chance to get recognized for that. So please vote &lt;a href="http://crunchies2008.techcrunch.com/votes/?nominee_id=36&amp;amp;category_id=7" target="_blank"&gt;here&lt;/a&gt;.
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/fsBsnmyBs7w" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/fsBsnmyBs7w/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2009/01/05/Vote-for-OpenX!-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=2d0ca62d-384c-443e-88b5-0999544b51be</guid>
      <pubDate>Mon, 05 Jan 2009 06:52:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=2d0ca62d-384c-443e-88b5-0999544b51be</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=2d0ca62d-384c-443e-88b5-0999544b51be</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2009/01/05/Vote-for-OpenX!-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=2d0ca62d-384c-443e-88b5-0999544b51be</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=2d0ca62d-384c-443e-88b5-0999544b51be</feedburner:origLink></item>
    <item>
      <title>OpenX Ad Management Software</title>
      <description>&lt;p&gt;In a side project I had to integrate a ad manager into a existing website. In fact all that there is to be done in add JavaScript or any other suitable tags to the HTML page. The big part is the ad manager. In the quest to find the good one I stumble on OpenX ad manager. This is by far one of the best open source well thought software.&lt;/p&gt;  &lt;p&gt;From a no nothing start point I think that the software is simple and straight forward enough to get you set up in a day. Download it, navigate the forum to get the little extra information to how to price and where to place ads. And you&amp;#8217;re ready to go.&lt;/p&gt;  &lt;p&gt;This software just gets me going, big thanks to the team for making this great open source software.&lt;/p&gt;  &lt;p&gt;OpenX give you a bunch of features, see &lt;a href="http://www.openx.org/en/products/benefits"&gt;http://www.openx.org/en/products/benefits&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.openx.org/"&gt;http://www.openx.org/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://forum.openx.org/"&gt;http://forum.openx.org/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/K9qptk0SH7Q" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/K9qptk0SH7Q/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/09/26/OpenX-Ad-Management-Software-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=28b32b7f-b257-463a-b876-ec2633537917</guid>
      <pubDate>Fri, 26 Sep 2008 15:49:10 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=28b32b7f-b257-463a-b876-ec2633537917</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=28b32b7f-b257-463a-b876-ec2633537917</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/09/26/OpenX-Ad-Management-Software-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=28b32b7f-b257-463a-b876-ec2633537917</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=28b32b7f-b257-463a-b876-ec2633537917</feedburner:origLink></item>
    <item>
      <title>How to: use Foreach in C#</title>
      <description>&lt;p&gt;Understanding foreach was one of the toughest learning experience I had to go trough when learning C#. Foreach is use to iterate trough an&lt;a href="http://en.wikipedia.org/wiki/Array"&gt;Array&lt;/a&gt; or a &lt;a href="http://en.wikipedia.org/wiki/Collection_class"&gt;Collection&lt;/a&gt;. When searching the web for examples of how to actually use it I never found enough. I decided to show a couple of example that I would of wish I had found at the time. &lt;p&gt;&lt;a href="http://msdn.com"&gt;msdn&lt;/a&gt; says: The &lt;b&gt;foreach&lt;/b&gt; statement repeats a group of embedded statements for each element in an array or an object collection. The &lt;b&gt;foreach&lt;/b&gt;statement is used to iterate through the collection to get the desired information, but should not be used to change the contents of the collection to avoid unpredictable side effects. The statement takes the following form:&lt;pre&gt;foreach (type identifier in expression) statement&lt;/pre&gt;&lt;pre&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ttw7t8t6(vs.71).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ttw7t8t6(vs.71).aspx&lt;/a&gt;&lt;/pre&gt;
&lt;p&gt;In my first example I first built an &lt;a href="http://msdn2.microsoft.com/en-us/library/system.array.aspx"&gt;Array&lt;/a&gt; of 5 object, then for each object contained in the array I write a line on the web page.[]&lt;pre class="brush: csharp;"&gt;string[] myArray = new string[5];

myArray[0] = "One";
myArray[1] = "Two";
myArray[2] = "Three";
myArray[3] = "Four";
myArray[4] = "Five";

foreach (object arrayObject in myArray)
{
    Response.Write(arrayObject + "&amp;lt;br /&amp;gt;");
}
&lt;/pre&gt;
&lt;p&gt;You Get:
&lt;p&gt;&lt;a href="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple1_2.gif"&gt;&lt;img border="0" alt="exemple1" src="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple1_thumb.gif" width="367" height="333"&gt;&lt;/a&gt;
&lt;p&gt;The parameters, &lt;a href="http://msdn2.microsoft.com/en-us/library/9kkx3h3c(vs.71).aspx"&gt;object&lt;/a&gt; is the type of repeated item I'm interested in. The arrayObject is the identifier (variable I declare to represent the array object), in in this context means the exact same thing then in the English language. myArray is the Array itself. I know I’m repeating the same information again, but since we are talking about iteration...
&lt;p&gt;In my second example I will be doing the same thing with different key words and using a for statement to built my array.&lt;pre class="brush: csharp;"&gt;string[] secondExampleArray = new string[10];

for (int i = 0; i &amp;lt; 10; i++)
    secondExampleArray[i] = "Number " + i;

foreach (object sEA in secondExampleArray)
    Response.Write(sEA + "&amp;lt;br /&amp;gt;");
&lt;/pre&gt;
&lt;p&gt;You Get:
&lt;p&gt;&lt;a href="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple2_2.gif"&gt;&lt;img border="0" alt="exemple2" src="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple2_thumb.gif" width="367" height="333"&gt;&lt;/a&gt;
&lt;p&gt;This second example is more straight forward. I really wanted to show you an alternative way to write it. Remember that the first index is away* [0].
&lt;p&gt;In this third example I'll show you how to use if with a collection. I will use a &lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.datatable(VS.71).aspx"&gt;DataTable&lt;/a&gt; and iterate trough the rows. You could also use a&lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.dataset(VS.71).aspx"&gt;DataSet&lt;/a&gt; that contains one or more DataTable. Here is where it gets interesting, unlike the object the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.data.datarow(vs.71).aspx"&gt;DataRow&lt;/a&gt; contains an array of data. it's easy to get confused and search hours how to access the data. The quick solution is if you initialized our DataRow as row, you would get the first table column object of the array by row[0]. I'm using the &lt;a href="http://weblog.simondeshaies.com/post/2008/03/How-To-Connect-to-SQL-using-C-and-SELECT2c-INSERT-or-any-other-SQL-STATEMENT.aspx"&gt;SqlConnection&lt;/a&gt; class here as connection.&lt;pre class="brush: csharp;"&gt;using (SqlConnection connection = new SqlConnection())
{
    SqlDataAdapter adapter = new SqlDataAdapter(
        "SELECT [UserName],[UserAge],[UserID] FROM [MyDatabase].[dbo].[Users] ORDER BY [UserID]"
        , connection.Connection);
    DataTable dataTable = new DataTable();
    adapter.Fill(dataTable);
    
    foreach (DataRow row in dataTable.Rows)
        Response.Write(Convert.ToString(row[2]) 
            + " " + Convert.ToString(row[0]) 
            + " " + Convert.ToString(row[1]) 
            + "&amp;lt;br /&amp;gt;");
}

&lt;/pre&gt;&lt;pre&gt;You Get:&lt;/pre&gt;&lt;pre&gt;&lt;a href="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple3_2.gif"&gt;&lt;img border="0" alt="exemple3" src="http://weblog.simondeshaies.com/image.axd?picture=WindowsLiveWriter/HowtouseForeachinCSimonDeshaies_12046/exemple3_thumb.gif" width="367" height="333"&gt;&lt;/a&gt; &lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;Now the possibility are limitless...
&lt;p&gt;You may download the sample web site it contains all the code, the SqlConnection class and the database. &lt;a href="http://weblog.simondeshaies.com/sample/Foreach.zip"&gt;Have Fun!&lt;/a&gt;
&lt;p&gt;Please leave comments about the appreciation of my articles it means allot to me.&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/4qGpFivoa70" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/4qGpFivoa70/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/04/16/How-to-use-Foreach-in-C-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=5be63ec2-7d76-4e9c-9177-33dc6702ed75</guid>
      <pubDate>Wed, 16 Apr 2008 15:41:55 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=5be63ec2-7d76-4e9c-9177-33dc6702ed75</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=5be63ec2-7d76-4e9c-9177-33dc6702ed75</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/04/16/How-to-use-Foreach-in-C-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=5be63ec2-7d76-4e9c-9177-33dc6702ed75</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=5be63ec2-7d76-4e9c-9177-33dc6702ed75</feedburner:origLink></item>
    <item>
      <title>Say no to IE 6, savethedevelopers.org</title>
      <description>&lt;p&gt;
&lt;strong&gt;Say no to IE 6&lt;/strong&gt;! Our current campaign focuses on assisting users in upgrading their Internet Explorer 6 web browser. This campaign will result in former IE 6 users having a more enjoyable experience on the web while (hopefully) creating a less stressful and complicated environment for web developers by hastening the retirement of an outdated browser. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Join the Movement! &lt;/strong&gt;&lt;br /&gt;
If you&amp;#39;d like to support our cause, you may do so by going door to door urging the inhabitants of your town to upgrade their browsers. Alternatively, you can place a call to our browser detection/upgrade recommendation script on your site to show your support: 
&lt;/p&gt;
&lt;p&gt;
&lt;script src="http://www.savethedevelopers.org/say.no.to.ie.6.js"&gt;
&lt;/script&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://savethedevelopers.org/"&gt;http://savethedevelopers.org/&lt;/a&gt; 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/EqDbQZ2uOvk" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/EqDbQZ2uOvk/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/04/16/Say-no-to-IE-62c-savethedevelopersorg-7cSimon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=3d9204f5-db9f-45b1-91c5-06f9e11767fc</guid>
      <pubDate>Wed, 16 Apr 2008 13:49:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=3d9204f5-db9f-45b1-91c5-06f9e11767fc</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=3d9204f5-db9f-45b1-91c5-06f9e11767fc</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/04/16/Say-no-to-IE-62c-savethedevelopersorg-7cSimon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=3d9204f5-db9f-45b1-91c5-06f9e11767fc</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=3d9204f5-db9f-45b1-91c5-06f9e11767fc</feedburner:origLink></item>
    <item>
      <title>CSS Naked Day</title>
      <description>&lt;p&gt;
It&amp;#39;s a little late but I removed my cascading style sheet from my weblog. Participating in this event is great and I like the idea of supporting web standards. Though what really got my to participate is that msdn did, great? Not! I couldn&amp;rsquo;t get to the .NET Framework Library, so, I had to stop my work for tonight. My Rant. 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/Vacr3RmjRco" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/Vacr3RmjRco/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/04/09/CSS-Naked-Day-7c-Simon-Deshaies.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=bdd719c5-df7f-438e-871c-10644c5538f5</guid>
      <pubDate>Wed, 09 Apr 2008 20:04:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=bdd719c5-df7f-438e-871c-10644c5538f5</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=bdd719c5-df7f-438e-871c-10644c5538f5</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/04/09/CSS-Naked-Day-7c-Simon-Deshaies.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=bdd719c5-df7f-438e-871c-10644c5538f5</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=bdd719c5-df7f-438e-871c-10644c5538f5</feedburner:origLink></item>
    <item>
      <title>Six LinkedIn Best Practices</title>
      <description>&lt;p&gt;
&lt;font size="3"&gt;&lt;font face="Calibri"&gt;This blog was initially about .NET development, and I find myself to diverge from that goal more and more. But this, is also about development, about professional development.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;a href="http://www.linkedin.com/in/laurencevirtuedeshaies" title="Laurence LinkedIn Profile"&gt;Laurence&lt;/a&gt; and I composed together some best practices on how to use &lt;a href="http://linkedin.com/" title="LinkedIn"&gt;LinkedIn&lt;/a&gt;, to better your professional standing. By following these practices you will better your career. When I followed them I better my professional standing over night.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;/p&gt;
&lt;blockquote&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;1.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Read, &lt;a href="http://blog.linkedin.com/blog/2007/07/ten-ways-to-use.html" title="Ten Ways to Use LinkedIn | Guy Kawasaki"&gt;Ten Ways to Use LinkedIn | Guy Kawasaki&lt;/a&gt; article and follow his 10 steps their real and they help.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;2.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Follow LinkedIn advice, it&amp;rsquo;s the best, they are not trying to cost you but really help you.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;3.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Present yourself, fill out the profile page, add all your career position you worked and that you are occupying as small they may seem.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;4.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Search and Invite. Search LinkedIn for all the existing peoples you know and work with they might already be on there. Invite everyone you know, they might know someone that is on LinkedIn and can help you with your career. Or some co-worker in their next job might need your skill set.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;5.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Recommend and be recommended. Recommend your colleagues, the people you work with and your clients, they&amp;rsquo;ll appreciate and you break the ice so you can ask them in return. Employers and clients look for this and some require it.&lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
	&lt;p&gt;
	&lt;span&gt;&lt;span&gt;&lt;font face="Calibri" size="3"&gt;6.&lt;/font&gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Frequently ask questions, answering them will demonstrate that you are dynamic and capable in your industry. Answer the question ask by your target market first this will help you break the ice and get new customers. &amp;nbsp;Asking them will initiate business relationship that ultimately pay off. &lt;/font&gt;&lt;/font&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt; 
	&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Once you&amp;rsquo;ve applied these, have your friends, colleagues, clients and employers read these LinkedIn best practices, apply them and your network is growing.&lt;/font&gt;&lt;/font&gt; 
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/akwDyxRJ7ko" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/akwDyxRJ7ko/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/03/22/Six-LinkedIn-Best-Practices.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=5a24d535-e9ce-4c5c-8c88-70e44a7b58b2</guid>
      <pubDate>Sat, 22 Mar 2008 13:16:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=5a24d535-e9ce-4c5c-8c88-70e44a7b58b2</pingback:target>
      <slash:comments>3</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=5a24d535-e9ce-4c5c-8c88-70e44a7b58b2</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/03/22/Six-LinkedIn-Best-Practices.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=5a24d535-e9ce-4c5c-8c88-70e44a7b58b2</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=5a24d535-e9ce-4c5c-8c88-70e44a7b58b2</feedburner:origLink></item>
    <item>
      <title>PDF Bad Image Problem (Pixilated)</title>
      <description>&lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;
&lt;font face="Calibri" size="3"&gt;For the last few days I&amp;#39;ve been trying to print a PDF, it&amp;#39;s the first time I really try to&amp;nbsp;print a PDF since I got Windows Vista. My problem was bad images, they were fine in excel and word but once printed trough &lt;a href="http://www.adobe.com" title="Adobe Web Site"&gt;Adobe PDF&lt;/a&gt;, &lt;a href="http://www.biopdf.com" title="bioPDF Official Site "&gt;bioPDF&lt;/a&gt; or &lt;a href="http://pdf995.com/" title="995 Software Site"&gt;PDF995&lt;/a&gt;. It all came out the same, &lt;a href="http://weblog.simondeshaies.net/sample/ppdf.pdf" target="_blank" title="pixilated pdf"&gt;pixilated&lt;/a&gt;. &lt;/font&gt;
&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;
&lt;font face="Calibri" size="3"&gt;After many tests and some research I came across &lt;/font&gt;&lt;a href="http://www.adobe.com/print/events/pdf/Shaffer.pdf" title="Meet the perfect PDF"&gt;&lt;font face="Calibri" size="3"&gt;this article&lt;/font&gt;&lt;/a&gt;&lt;font face="Calibri" size="3"&gt; written by Julie Shaffer of &amp;quot;Center for Imaging Excellence&amp;quot;. &lt;/font&gt;&lt;font face="Calibri" size="3"&gt;It basically explains how to avoid bad PDF. But her suggested configuration did not quite fit with my favored PDF printer, &lt;a href="http://www.biopdf.com" title="bioPDF Official Site "&gt;bioPDF&lt;/a&gt;. The &amp;quot;Output Protocol&amp;quot; &amp;quot;&lt;a href="http://en.wikipedia.org/wiki/Binary" title="Wiki Binary"&gt;Binary&lt;/a&gt;&amp;quot; does not work with my computer configuration, I had to use &amp;quot;&lt;a href="http://en.wikipedia.org/wiki/Ascii" title="Wiki Ascii"&gt;ASCII&lt;/a&gt;&amp;quot;.&lt;/font&gt; &lt;font face="Calibri" size="3"&gt;My two main errors were also&amp;nbsp;that my images were less than 300 dpi and had transparent backgrounds.&lt;/font&gt; 
&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;
&lt;font face="Calibri" size="3"&gt;Wirter PDF &amp;ndash; bioPDF &amp;ndash; Printer Configuration&lt;/font&gt; 
&lt;/p&gt;
&lt;img style="width: 600px; height: 691px" src="/sample/images/biopdfconfig.gif" alt="Wirter PDF &amp;ndash; bioPDF &amp;ndash; Printer Configuration" width="600" height="691" /&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/OhC60tcCiPE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/OhC60tcCiPE/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/03/20/PDF-Bad-Image-Problem-(Pixilated).aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=a32f2af0-136c-4f2e-a988-43dbe041f56d</guid>
      <pubDate>Thu, 20 Mar 2008 11:34:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=a32f2af0-136c-4f2e-a988-43dbe041f56d</pingback:target>
      <slash:comments>2</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=a32f2af0-136c-4f2e-a988-43dbe041f56d</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/03/20/PDF-Bad-Image-Problem-(Pixilated).aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=a32f2af0-136c-4f2e-a988-43dbe041f56d</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=a32f2af0-136c-4f2e-a988-43dbe041f56d</feedburner:origLink></item>
    <item>
      <title>How to: float?</title>
      <description>&lt;p&gt;In web design, one of my favorite CSS propriety is float. Here I&amp;rsquo;ll demonstrate how to use it to built a page header. In this simple example I float every section left.&lt;/p&gt;

&lt;pre class="brush: css;"&gt;body
{
    padding: 0px;
    font-family: Century Gothic, Tahoma, Sans-Serif;
    font-size: small;
}
.ContentPlaceHolder
{
    /* this is to center the content in the browser page*/
    margin: 0 auto;
    width: 800px;

    border: solid 1px gray;
    height: 100%;
}
.PageHead
{
    width: 800px;
    height: 100px;
}
.PageBody
{
    width: 800px;
    height: 600px;
}
.FloatingLayer
{
    float: left;
    width: 266px;
}
&lt;/pre&gt;

&lt;pre class="brush: xml;"&gt;&amp;lt;div class="ContentPlaceHolder"&amp;gt;
    &amp;lt;div class="PageHead"&amp;gt;
        &amp;lt;div class="FloatingLayer"&amp;gt;
            &amp;lt;img src="http://weblog.simondeshaies.com/sample/support.png" alt="Support Logo" /&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;div class="FloatingLayer" style="text-align: center;"&amp;gt;
            &amp;lt;h1&amp;gt;
                My Web Site!&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="FloatingLayer" style="text-align: right;"&amp;gt;
            &amp;lt;a href="#"&amp;gt;My Link&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div class="PageBody"&amp;gt;
        My Content Here&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;
[]&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/0C_Xfvhf9Wk" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/0C_Xfvhf9Wk/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/03/18/How-to-float.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=47db10b7-1f6a-4546-b314-c1508ee247b3</guid>
      <pubDate>Tue, 18 Mar 2008 16:52:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=47db10b7-1f6a-4546-b314-c1508ee247b3</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=47db10b7-1f6a-4546-b314-c1508ee247b3</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/03/18/How-to-float.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=47db10b7-1f6a-4546-b314-c1508ee247b3</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=47db10b7-1f6a-4546-b314-c1508ee247b3</feedburner:origLink></item>
    <item>
      <title>How To: Connect to SQL using C# and SELECT, INSERT or any other SQL STATEMENT?</title>
      <description>&lt;p&gt;I started a &lt;a href="http://forums.asp.net/t/1193643.aspx"&gt;thread&lt;/a&gt; on the asp.net forums a while back wanting to share with the others a easy way to connect to SQL. Since then I perfected quite a bit the code and made it a class.cs file, that can be up and running in a few minutes. &lt;/p&gt;  &lt;p&gt;Connecting to SQL using the design view in visual studio is quite easy and straight forward. I found to be somewhat limited though. Having a class that you can invoke in all your application and in other classes is the works. &lt;/p&gt;  &lt;p&gt;Here I demonstrate how to use C# in a class file to connect to SQL, and INSERT, SELECT or UPDATE an existing SQL database. In this example I will be using the Microsoft SQL Express Server. Also the connection string in this example is using integrated SQL security; if you need to connect to an external server or any other king of SQL server go to &lt;a href="http://connectionstrings.com"&gt;http://connectionstrings.com&lt;/a&gt; to get the replacement connection string code. &lt;/p&gt;  &lt;p&gt;First off unlike asp.net insert you don’t use a connection string in the web.config, you can but for sake of simplicity it does not. If that’s your goal, the class is commented on hot to do that. &lt;/p&gt;  &lt;p&gt;Add an .cs file to your solution and paste the following code. Be weary of the namespace either rename or remove it. &lt;/p&gt; [] &lt;pre class="brush: csharp;"&gt;using System;
using System.Configuration;

namespace ToolBox
{
    /// &amp;lt;summary&amp;gt;
    /// SqlConnection class connects to SQL and when
    /// disposed it closes the connection to SQL.
    /// &amp;lt;/summary&amp;gt;
    public sealed class SqlConnection : IDisposable
    {
        #region Properties
        public System.Data.SqlClient.SqlConnection Connection { get; set; }
        public System.Data.SqlClient.SqlDataReader DataReader { get; set; }
        public System.Data.SqlClient.SqlCommand Command { get; set; }
        #endregion

        #region Constructors
        /// &amp;lt;summary&amp;gt;
        /// Instanciate SqlConnection and open connection to SQL Server
        /// &amp;lt;/summary&amp;gt;
        public SqlConnection()
        {
            //New up the SqlConnection class
            if (Connection == null)
                Connection = new System.Data.SqlClient.SqlConnection();

            // Assign the connection string
            //
            // It can be also saved in the .config file
            //&amp;lt;connectionStrings&amp;gt;
            //&amp;lt;add name=&amp;quot;MyConnectionString&amp;quot; 
            //      connectionString=&amp;quot;server=SERVERNAME;database=DATABASENAME;Trusted_Connection=True;&amp;quot;
            //      providerName=&amp;quot;System.Data.SqlClient&amp;quot; /&amp;gt;
            //&amp;lt;/connectionStrings&amp;gt;
            //Uncomment the following line to get it form the configuration file
            //Connection.ConnectionString = ConfigurationManager.ConnectionStrings[&amp;quot;MyConnectionString&amp;quot;].ConnectionString;

            Connection.ConnectionString = &amp;quot;server=SERVERNAME;database=DATABASENAME;Trusted_Connection=True;&amp;quot;;

            //Open the connection
            Open();
        }
        #endregion

        /// &amp;lt;summary&amp;gt;
        /// Opens a connection to SQL
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;returns&amp;gt;Connected System.Data.SqlClient.SqlConnection&amp;lt;/returns&amp;gt;
        private void Open()
        {
            //Attempt to connect and catch exception
            if (Connection.State != System.Data.ConnectionState.Open)
                try
                {
                    //Try to connect with a short timeout and pooling
                    Connection.ConnectionString = 
                        String.Format(
                        &amp;quot;Min Pool Size=1;Max Pool Size=10;Connect Timeout=4;{0}&amp;quot;
                        , Connection.ConnectionString);
                    Connection.Open();
                }
                catch
                {
                    //If connection failed, try again without pooling and a linger timeout
                    if (Connection.State != System.Data.ConnectionState.Closed)
                        Connection.Close();

                    Connection.ConnectionString = 
                        String.Format(
                        &amp;quot;Pooling=false;Connect Timeout=45;{0}&amp;quot;
                        , Connection.ConnectionString);
                    Connection.Open();
                }
        }

        #region IDisposable Members

        // Track whether Dispose has been called.
        private Boolean disposed = false;

        /// &amp;lt;summary&amp;gt;
        /// Implement IDisposable.

        /// Do not make this method virtual.
        /// A derived class should not be able to override this method.
        /// &amp;lt;/summary&amp;gt;
        public void Dispose()
        {
            Dispose(true);
            // This object will be cleaned up by the Dispose method.
            // Therefore, you should call GC.SupressFinalize to
            // take this object off the finalization queue
            // and prevent finalization code for this object
            // from executing a second time.
            GC.SuppressFinalize(this);
        }

        /// &amp;lt;summary&amp;gt;
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name=&amp;quot;disposing&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                lock (this)
                {
                    // If disposing equals true, dispose all managed
                    // and unmanaged resources.
                    if (disposing)
                    {
                        Connection.Dispose();
                        if (DataReader != null)
                            DataReader.Dispose();
                        if (Command != null)
                            Command.Dispose();
                    }
                    // Note disposing has been done.
                    disposed = true;
                }
            }
        }

        /// &amp;lt;summary&amp;gt;
        /// Use C# destructor syntax for finalization code.
        /// This destructor will run only if the Dispose method
        /// does not get called.
        /// It gives your base class the opportunity to finalize.
        /// Do not provide destructors in types derived from this class.
        /// &amp;lt;/summary&amp;gt;
        ~SqlConnection()
        {
            Dispose(false);
        }

        #endregion
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;IDisposable Interface &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the class contains property that implement IDisposable interface, the rule is that the class also has to implement it. IDisposable offer 2 very nice way to use the calss:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. With a using statement:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using (SqlConnection connection = new SqlConnection())
{
    //Do something
}&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;2. With try / finally statement:&lt;/strong&gt;&amp;#160; &lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;SqlConnection connection = new SqlConnection();
try
{
    //Do something
}
finally
{
    connection.Dispose();
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre&gt;&lt;strong&gt;&lt;font face="Verdana"&gt;Usage&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;Here are some examples on how to use the class, in the examples I prefer the using statement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SELECT:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using (SqlConnection connection = new SqlConnection())
{
    connection.Command = connection.Connection.CreateCommand();
    connection.Command.CommandType = System.Data.CommandType.Text;
    connection.Command.Parameters.Add(&amp;quot;@Name&amp;quot;, System.Data.SqlDbType.NVarChar);
    connection.Command.Parameters[&amp;quot;@Name&amp;quot;].Value = &amp;quot;Simon&amp;quot;;
    connection.Command.CommandText = @&amp;quot;SELECT *FORM [dbo].[table1] WHERE [Name] = @Name&amp;quot;;
    connection.DataReader = connection.Command.ExecuteReader();
    while (connection.DataReader.Read())
    {
        //Do something
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;INSERT:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;
using (SqlConnection connection = new SqlConnection())
{
     connection.Command = connection.Connection.CreateCommand();
     connection.Command.CommandType = System.Data.CommandType.Text;
     connection.Command.Parameters.Add(&amp;quot;@Value&amp;quot;, System.Data.SqlDbType.NVarChar);
     connection.Command.Parameters[&amp;quot;@Value&amp;quot;].Value = &amp;quot;Simon&amp;quot;;
     connection.Command.CommandText = @&amp;quot;INSERT INTO [dbo].[table1] VALUES (@Name)&amp;quot;;
     connection.Command.ExecuteNonQuery();
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonDeshaies/~4/Am3zE4PO5w8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/SimonDeshaies/~3/Am3zE4PO5w8/post.aspx</link>
      <author>Simon Deshaies</author>
      <comments>http://weblog.simondeshaies.net/post/2008/03/12/How-To-Connect-to-SQL-using-C-and-SELECT2c-INSERT-or-any-other-SQL-STATEMENT.aspx#comment</comments>
      <guid isPermaLink="false">http://weblog.simondeshaies.net/post.aspx?id=5d87ce2b-8ab5-4093-8b59-2752cebf54d0</guid>
      <pubDate>Wed, 12 Mar 2008 06:10:00 -1000</pubDate>
      <dc:publisher>Simon Deshaies</dc:publisher>
      <pingback:server>http://weblog.simondeshaies.net/pingback.axd</pingback:server>
      <pingback:target>http://weblog.simondeshaies.net/post.aspx?id=5d87ce2b-8ab5-4093-8b59-2752cebf54d0</pingback:target>
      <slash:comments>25</slash:comments>
      <trackback:ping>http://weblog.simondeshaies.net/trackback.axd?id=5d87ce2b-8ab5-4093-8b59-2752cebf54d0</trackback:ping>
      <wfw:comment>http://weblog.simondeshaies.net/post/2008/03/12/How-To-Connect-to-SQL-using-C-and-SELECT2c-INSERT-or-any-other-SQL-STATEMENT.aspx#comment</wfw:comment>
      <wfw:commentRss>http://weblog.simondeshaies.net/syndication.axd?post=5d87ce2b-8ab5-4093-8b59-2752cebf54d0</wfw:commentRss>
    <feedburner:origLink>http://weblog.simondeshaies.net/post.aspx?id=5d87ce2b-8ab5-4093-8b59-2752cebf54d0</feedburner:origLink></item>
  </channel>
</rss>
