<?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>the jackol's den &#187; Tips</title>
	<atom:link href="http://www.thejackol.com/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thejackol.com</link>
	<description>01100010 01101100 01100101 01101000</description>
	<lastBuildDate>Tue, 31 Aug 2010 11:20:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>LINQ to SQL log to debug window, file, memory or multiple writers</title>
		<link>http://www.thejackol.com/2010/08/05/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers/</link>
		<comments>http://www.thejackol.com/2010/08/05/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 13:46:06 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[C#/.NET]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=669</guid>
		<description><![CDATA[From here class DebugTextWriter : System.IO.TextWriter { public override void Write(char[] buffer, int index, int count) { System.Diagnostics.Debug.Write(new String(buffer, index, count)); } public override void Write(string value) { System.Diagnostics.Debug.Write(value); } public override Encoding Encoding { get { return System.Text.Encoding.Default; } } }]]></description>
			<content:encoded><![CDATA[	<p>From <a href="http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers">here</a></p>

<pre><code>class DebugTextWriter : System.IO.TextWriter {
   public override void Write(char[] buffer, int index, int count) {
       System.Diagnostics.Debug.Write(new String(buffer, index, count));
   }
</code>
<code>   public override void Write(string value) {
       System.Diagnostics.Debug.Write(value);
   }
</code>
<code>   public override Encoding Encoding {
       get { return System.Text.Encoding.Default; }
   }
}
</code></pre>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2010/08/05/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevent One Click Attacks by setting ViewStateUserKey in ASP.NET applications</title>
		<link>http://www.thejackol.com/2009/09/14/prevent-one-click-attacks-by-setting-viewstateuserkey-in-asp-net-applications/</link>
		<comments>http://www.thejackol.com/2009/09/14/prevent-one-click-attacks-by-setting-viewstateuserkey-in-asp-net-applications/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 20:11:08 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[C#/.NET]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=633</guid>
		<description><![CDATA[Here&#8217;s an easy way to avoid One Click Attacks in ASP.NET applications. If you have a Base class that all your ASP.NET pages derive from, override the OnInit function. For example: protected override void OnInit(EventArgs e) { base.OnInit(e); if (User.Identity.IsAuthenticated) ViewStateUserKey = User.Identity.Name; } If you don&#8217;t have a base class defined, you would have [...]]]></description>
			<content:encoded><![CDATA[	<p>Here&#8217;s an easy way to avoid <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">One Click Attacks</a> in <span class="caps">ASP</span>.<span class="caps">NET</span> applications. If you have a Base class that all your <span class="caps">ASP</span>.<span class="caps">NET</span> pages derive from, override the <code>OnInit</code> function. For example:</p>

<pre><code>protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
</code>
<code>    if (User.Identity.IsAuthenticated)
        ViewStateUserKey = User.Identity.Name;
}
</code></pre>

	<p>If you don&#8217;t have a base class defined, you would have to put the above code in every <span class="caps">ASP</span>.<span class="caps">NET</span> page.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/09/14/prevent-one-click-attacks-by-setting-viewstateuserkey-in-asp-net-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing BugZilla 3.4.1 on Dreamhost</title>
		<link>http://www.thejackol.com/2009/08/24/installing-bugzilla-3-4-1-on-dreamhost/</link>
		<comments>http://www.thejackol.com/2009/08/24/installing-bugzilla-3-4-1-on-dreamhost/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 14:17:18 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bugzilla]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=630</guid>
		<description><![CDATA[Here&#8217;s a quick guide on installing Bugzilla 3.4.1 on Dreamhost. Fire up a shell and follow these steps (these command are from http://wiki.dreamhost.com/Bugzilla) in the directory of the domain you want to install Bugzilla in. mkdir bugs cd bugs wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-STABLE.tar.gz tar zxf bugzilla-STABLE.tar.gz rm bugzilla-STABLE.tar.gz mv bugzilla*/* . Next, follow setups 6, 7, 8 [...]]]></description>
			<content:encoded><![CDATA[	<p>Here&#8217;s a quick guide on installing Bugzilla 3.4.1 on Dreamhost.</p>

	<p>Fire up a shell and follow these steps (these command are from <a href="http://wiki.dreamhost.com/Bugzilla">http://wiki.dreamhost.com/Bugzilla</a>) in the directory of the domain you want to install Bugzilla in.</p>

<pre><code>mkdir bugs
cd bugs
wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-STABLE.tar.gz
tar zxf bugzilla-STABLE.tar.gz
rm bugzilla-STABLE.tar.gz
mv bugzilla*/* .
</code></pre>

	<p>Next, follow setups 6, 7, 8 and 9 from the <a href="http://wiki.dreamhost.com/Bugzilla">Bugzilla Dreamhost wiki</a>.</p>

	<p>Now you will need to manually install <code>Module::Build</code> and <code>DateTime::Locale</code> for Bugzilla to work. To do this, first get the latest <span class="caps">CPAN</span> download links for the modules.</p>

	<p>For Module::Build, you&#8217;ll find the download link here: <a href="http://search.cpan.org/~kwilliams/Module-Build/">http://search.cpan.org/~kwilliams/Module-Build/</a><br />
For DateTime::Locale, you&#8217;ll find the download at: <a href="http://search.cpan.org/~drolsky/DateTime-Locale-0.43/">http://search.cpan.org/~drolsky/DateTime-Locale-0.43/</a></p>

	<p>I&#8217;ve used the latest available builds at the time of this writing for the example below. Next, follow these steps in the Bugzilla installation directory:</p>

<pre><code>mkdir tmp
cd tmp
PERL5LIB=/full-path-to-bugzilla-install-dir/lib
export PERL5LIB
wget http://search.cpan.org/CPAN/authors/id/K/KW/KWILLIAMS/Module-Build-0.31.tar.gz
tar xzf Module-Build-0.31.tar.gz
cd Module-Build-0.31
perl Makefile.pl
make
make test
make install
cd ..
rm -rf Module-Build*
</code>
<code># To install DateTime::Locale
wget http://search.cpan.org/CPAN/authors/id/D/DR/DROLSKY/DateTime-Locale-0.43.tar.gz
tar zxf DateTime-Locale-0.43.tar.gz
cd DateTime-Locale-0.43
perl Makefile.pl
make
make test
make install
cd ../..
rm -rf tmp
</code></pre>

	<p>Re-run ./checksetup.pl and then fix permissions as in the Dreamhost Bugzilla wiki page:</p>

<pre><code>for i in docs graphs images js skins; do find $i -type d -exec chmod o+rx {} \; ; done
for i in jpg gif css js png html rdf xul; do find . -name \*.$i -exec chmod o+r {} \; ; done
find . -name .htaccess -exec chmod o+r {} \;
chmod o+x . data data/webdot
</code></pre>

	<p>You should now have a working Bugzilla installation at yourdomain.com/bugs.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/08/24/installing-bugzilla-3-4-1-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Encrypt your config please&#8230;</title>
		<link>http://www.thejackol.com/2009/07/23/encrypt-your-config-please/</link>
		<comments>http://www.thejackol.com/2009/07/23/encrypt-your-config-please/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 07:34:26 +0000</pubDate>
		<dc:creator>Raghavendra K</dc:creator>
				<category><![CDATA[C#/.NET]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=618</guid>
		<description><![CDATA[ASP.NET 2.0 makes encrypting configSections in the web.config file a snap and there is no reason to not encrypt sensitive configSections. Just google for &#8220;encrypt config&#8221; and there are tons of code snippets waiting for you to copy and paste. Below is a code snippet that is found most commonly in google search results for [...]]]></description>
			<content:encoded><![CDATA[	<p><span class="caps">ASP</span>.<span class="caps">NET</span> 2.0 makes encrypting configSections in the web.config file a snap and there is no reason to not encrypt sensitive configSections. Just google for &#8220;encrypt config&#8221; and there are tons of code snippets waiting for you to copy and paste. Below is a code snippet that is found most commonly in google search results for protecting and unprotecting web.config file:<br />
<pre><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> ProtectSection(</span><span style="color: #0000ff">string</span><span style="color: #000000"> sectionName, </span><span style="color: #0000ff">string</span><span style="color: #000000"> provider)<br />
{
    Configuration config </span><span style="color: #000000">=</span><span style="color: #000000"> WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);</p>

    ConfigurationSection section </span><span style="color: #000000">= </span><span style="color: #000000">config.GetSection(sectionName);

    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (section </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&amp;&amp; </span><span style="color: #000000">!</span><span style="color: #000000">section.SectionInformation.IsProtected)
    {
        section.SectionInformation.ProtectSection(provider);
        config.Save();
    }
}
</span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> UnProtectSection(</span><span style="color: #0000ff">string</span><span style="color: #000000"> sectionName)
{
    Configuration config </span><span style="color: #000000">=</span><span style="color: #000000"> WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

    ConfigurationSection section </span><span style="color: #000000">= </span><span style="color: #000000">config.GetSection(sectionName);

    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (section </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&amp;&amp; </span><span style="color: #000000">section.SectionInformation.IsProtected)
    {
        section.SectionInformation.UnprotectSection();
        config.Save();
    }
}
</span><span style="color: #000000"> </span></pre>
You would usually call <strong>ProtectSection </strong>method in the <strong>Application_Start</strong> event in global.asax. As you can see, it accepts two parameters, sectionName (like &#8220;connectionStrings&#8221;) and provider which is basically an encryption services provider. <span class="caps">ASP</span>.<span class="caps">NET</span> ships with 2 default providers:
<ul>
	<li>The Windows Data Protection <span class="caps">API</span> (<span class="caps">DPAPI</span>) Provider (<strong>DataProtectionConfigurationProvider</strong>)
If you use this provider then the encryption keys are provided by the Windows OS. You don&#8217;t need to maintain the keys. However, this also means that you will need to deploy you application initially with a plain-text config file and then wait for your application logic to actually encrypt it.</li>
</ul>
<ul>
	<li><span class="caps">RSA</span> Protected Configuration Provider (<strong>RSAProtectedConfigurationProvider</strong>)
If you use this options then you are also required to create key containers to hold the public and private keys used for encrypting and decrypting the config information.</li>
</ul>
Once the data is encrypted, you don&#8217;t need to change anything in your code while accessing the settings. The <span class="caps">ASP</span>.<span class="caps">NET</span> configuration classes are smart enough to decrypt and provide you plain-text when they come across encrypted configSections. Pretty cool eh!

	<p>Please note that you may never need to invoke the UnprotectSection method. It is only provided, just in case you want to revert back to a plain-text config file.</p>

	<p>For a complete detailed tutorial on encrypting configSections see <a href="http://aspnet.4guysfromrolla.com/articles/021506-1.aspx" target="_blank">http://aspnet.4guysfromrolla.com/articles/021506-1.aspx</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/07/23/encrypt-your-config-please/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable UAC for Certain Applications in Vista</title>
		<link>http://www.thejackol.com/2009/07/15/disable-uac-for-certain-applications-in-vista/</link>
		<comments>http://www.thejackol.com/2009/07/15/disable-uac-for-certain-applications-in-vista/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 02:47:23 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=616</guid>
		<description><![CDATA[If you are a Windows Vista user, there is nothing more bugging than the UAC in Windows Vista. UAC which was supposed to bring improved security in Windows, does it pretty well but at the cost of user friendliness. There are lots of apps and softwares that I run on my Machine, and Vista bugs [...]]]></description>
			<content:encoded><![CDATA[	<blockquote>
		<p>If you are a Windows Vista user, there is nothing more bugging than the <span class="caps">UAC</span> in Windows Vista. <span class="caps">UAC</span> which was supposed to bring improved security in Windows, does it pretty well but at the cost of user friendliness.</p>
		<p>There are lots of apps and softwares that I run on my Machine, and Vista bugs me everytime I open them. For quite some time I’ve been looking to disable <span class="caps">UAC</span> for select applications, rather than disabling it all together, as that could possibly create a security havoc. After some time looking around for a solution, I finally found a solution that was recommended by Microsoft, and even Worked pretty well for me.</p>
		<p>If you are looking to disable <span class="caps">UAC</span> for certain applications in Windows Vista, then follow this guide, and once you are done, the <span class="caps">UAC</span> may not really be all that bugging as it used to be.</p>
	</blockquote>

	<p><a href="http://dailyapps.net/2008/01/hack-attack-disable-uac-for-certain-applications-in-vista/">Read more</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/07/15/disable-uac-for-certain-applications-in-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount ISO&#8217;s on 64-bit Windows Vista</title>
		<link>http://www.thejackol.com/2009/07/10/mount-isos-on-64-bit-windows-vista/</link>
		<comments>http://www.thejackol.com/2009/07/10/mount-isos-on-64-bit-windows-vista/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 13:20:55 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=611</guid>
		<description><![CDATA[MagicISO Virtual is a free software that works on Vista&#8217;s 64-bit edition. You&#8217;ll receive a warning when installing it &#8211; just click &#8220;Continue anyway&#8221;. From their site: MagicISO is very helpful utility designed for creating and managing virtual CD drives and CD/DVD discs. You can run programs, play games, or listen to music from your [...]]]></description>
			<content:encoded><![CDATA[	<p>MagicISO Virtual is a free software that works on Vista&#8217;s 64-bit edition. You&#8217;ll receive a warning when installing it &#8211; just click &#8220;Continue anyway&#8221;. From their site:</p>

	<blockquote>
		<p>MagicISO is very helpful utility designed for creating and managing virtual CD drives and CD/<span class="caps">DVD</span> discs. You can run programs, play games, or listen to music from your virtual <span class="caps">CD-ROM</span>. Allowing you to run your game images at over 200x faster than from a conventional CD/<span class="caps">DVD-ROM</span>. MagicDisc is a powerful utility that uses a unique combination of options to ensure a perfect back-up every time.</p>
	</blockquote>

	<p><a href="http://www.magiciso.com/tutorials/miso-magicdisc-overview.htm">Link</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/07/10/mount-isos-on-64-bit-windows-vista/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET AJAX CalendarExtender losing styles</title>
		<link>http://www.thejackol.com/2009/06/23/asp-net-ajax-calendarextender-losing-styles/</link>
		<comments>http://www.thejackol.com/2009/06/23/asp-net-ajax-calendarextender-losing-styles/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 20:01:35 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[C#/.NET]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=605</guid>
		<description><![CDATA[If the AJAX CalendarExtender control shows up without any style information or in the wrong places, the simplest solution is to copy the original CSS for the Calendar&#8217;s default style (located at AjaxControlToolkit\Calendar\Calendar.css into your application&#8217;s CSS file. Also make sure the CssClass property is not defined in your CalendarExtender. The actual content of the [...]]]></description>
			<content:encoded><![CDATA[	<p>If the <span class="caps">AJAX</span> CalendarExtender control shows up without any style information or in the wrong places, the simplest solution is to copy the original <span class="caps">CSS</span> for the Calendar&#8217;s default style (located at <code>AjaxControlToolkit\Calendar\Calendar.css</code> into your application&#8217;s <span class="caps">CSS</span> file. Also make sure the <code>CssClass</code> property is not defined in your <code>CalendarExtender</code>. The actual content of the default Calendar style is below:</p>

<pre><code>.ajax__calendar_container {padding:4px;position:absolute;cursor:default;width:170px;
    font-size:11px;text-align:center;font-family:tahoma,verdana,helvetica;}
.ajax__calendar_body {height:139px;width:170px;position:relative;overflow:hidden;
    margin:auto;}
.ajax__calendar_days, .ajax__calendar_months, .ajax__calendar_years {top:0px;left:0px;
    height:139px;width:170px;position:absolute;text-align:center;margin:auto;}
.ajax__calendar_container TABLE {font-size:11px;}
.ajax__calendar_header {height:20px;width:100%;}
.ajax__calendar_prev {cursor:pointer;width:15px;height:15px;float:left;
    background-repeat:no-repeat;background-position:50% 50%;
    background-image:url(&#60; %=WebResource(&#34;AjaxControlToolkit.Calendar.arrow-left.gif&#34;)%&#62;);}
.ajax__calendar_next {cursor:pointer;width:15px;height:15px;float:right;
    background-repeat:no-repeat;background-position:50% 50%;
    background-image:url(&#60; %=WebResource(&#34;AjaxControlToolkit.Calendar.arrow-right.gif&#34;)%&#62;);}
.ajax__calendar_title {cursor:pointer;font-weight:bold;}
.ajax__calendar_footer {height:15px;}
.ajax__calendar_today {cursor:pointer;padding-top:3px;}
.ajax__calendar_dayname {height:17px;width:17px;text-align:right;padding:0 2px;}
.ajax__calendar_day {height:17px;width:18px;text-align:right;padding:0 2px;cursor:pointer;}
.ajax__calendar_month {height:44px;width:40px;text-align:center;cursor:pointer;overflow:hidden;}
.ajax__calendar_year {height:44px;width:40px;text-align:center;cursor:pointer;overflow:hidden;}
</code>
<code>.ajax__calendar .ajax__calendar_container {border:1px solid #646464;background-color:#ffffff;
    color:#000000;}
.ajax__calendar .ajax__calendar_footer {border-top:1px solid #f5f5f5;}
.ajax__calendar .ajax__calendar_dayname {border-bottom:1px solid #f5f5f5;}
.ajax__calendar .ajax__calendar_day {border:1px solid #ffffff;}
.ajax__calendar .ajax__calendar_month {border:1px solid #ffffff;}
.ajax__calendar .ajax__calendar_year {border:1px solid #ffffff;}
</code>
<code>.ajax__calendar .ajax__calendar_active .ajax__calendar_day {background-color:#edf9ff;
    border-color:#0066cc;color:#0066cc;}
.ajax__calendar .ajax__calendar_active .ajax__calendar_month {background-color:#edf9ff;
    border-color:#0066cc;color:#0066cc;}
.ajax__calendar .ajax__calendar_active .ajax__calendar_year {background-color:#edf9ff;
    border-color:#0066cc;color:#0066cc;}
</code>
<code>.ajax__calendar .ajax__calendar_other .ajax__calendar_day {background-color:#ffffff;
    border-color:#ffffff;color:#646464;}
.ajax__calendar .ajax__calendar_other .ajax__calendar_year {background-color:#ffffff;
    border-color:#ffffff;color:#646464;}
</code>
<code>.ajax__calendar .ajax__calendar_hover .ajax__calendar_day {background-color:#edf9ff;
    border-color:#daf2fc;color:#0066cc;}
.ajax__calendar .ajax__calendar_hover .ajax__calendar_month {background-color:#edf9ff;
    border-color:#daf2fc;color:#0066cc;}
.ajax__calendar .ajax__calendar_hover .ajax__calendar_year {background-color:#edf9ff;
    border-color:#daf2fc;color:#0066cc;}
</code>
<code>.ajax__calendar .ajax__calendar_hover .ajax__calendar_title {color:#0066cc;}
.ajax__calendar .ajax__calendar_hover .ajax__calendar_today {color:#0066cc;}
</code></pre>

	<p>#</p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/06/23/asp-net-ajax-calendarextender-losing-styles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get LINQ to SQL results into a DataTable</title>
		<link>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/</link>
		<comments>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:33:09 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[C#/.NET]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[linq to sql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=594</guid>
		<description><![CDATA[There are two ways to get LINQ to SQL results into a DataTable, as explained here. I use Sample II: public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query) { if (query == null) { throw new ArgumentNullException(&#34;query&#34;); } IDbCommand cmd = ctx.GetCommand(query as IQueryable); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = (SqlCommand)cmd; DataTable dt = new DataTable(&#34;sd&#34;); [...]]]></description>
			<content:encoded><![CDATA[	<p>There are two ways to get <span class="caps">LINQ</span> to <span class="caps">SQL</span> results into a DataTable, <a href="http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx" ref="external nofollow">as explained here</a>.</p>

	<p>I use Sample II:</p>

<pre><code>public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
{
     if (query == null)
     {
          throw new ArgumentNullException(&#34;query&#34;);
     }
</code>
<code>     IDbCommand cmd = ctx.GetCommand(query as IQueryable);
     SqlDataAdapter adapter = new SqlDataAdapter();
     adapter.SelectCommand = (SqlCommand)cmd;
     DataTable dt = new DataTable(&#34;sd&#34;);
</code>
<code>     try
     {
          cmd.Connection.Open();
          adapter.FillSchema(dt, SchemaType.Source); 
          adapter.Fill(dt);
     }
     finally
     {
          cmd.Connection.Close();
     }
     return dt;
}
</code></pre>

	<p>//</p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
