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

<channel>
	<title>Web Development Blog - webdoubt.com</title>
	<atom:link href="http://www.webdoubt.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdoubt.com</link>
	<description>ASP.NET - AJAX.NET - SQL Server - Ruby on Rails - mySQL - Web Development Blog</description>
	<pubDate>Fri, 18 Dec 2009 01:59:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>What is the difference between calories and fat?</title>
		<link>http://www.webdoubt.com/what-is-the-difference-between-calories-and-fat/</link>
		<comments>http://www.webdoubt.com/what-is-the-difference-between-calories-and-fat/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 01:57:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Diet]]></category>

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

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=48</guid>
		<description><![CDATA[What&#8217;s the difference between fat and calories?
Fat is one of six nutrients your body needs to stay healthy. The other five nutrients are:

Carbohydrates (found in fruits, vegetables, pasta, rice, grains, peas, beans, and other legumes)
Proteins (found in meat, poultry, dairy products, eggs, and beans)
Minerals (such as potassium, calcium, and iron)
Vitamins (such as vitamins A, D, [...]]]></description>
			<content:encoded><![CDATA[<h2>What&#8217;s the difference between fat and calories?</h2>
<p>Fat is one of six nutrients your body needs to stay healthy. The other five nutrients are:</p>
<ul>
<li>Carbohydrates (found in fruits, vegetables, pasta, rice, grains, peas, beans, and other legumes)</li>
<li>Proteins (found in meat, poultry, dairy products, eggs, and beans)</li>
<li>Minerals (such as potassium, calcium, and iron)</li>
<li>Vitamins (such as vitamins A, D, E, and K)</li>
<li>Water</li>
</ul>
<p>Of these six nutrients, carbohydrates, protein and fats provide calories. Each gram of carbohydrate and protein yield 4 calories/gram. Each gram of fat yields 9 calories.</p>
<p>A calorie is a measurement, just like a teaspoon or an inch. Calories are the amount of energy released when your body breaks down (digests and absorbs) food. The more calories a food has, the more energy it can provide to your body. When you eat more calories than you need, your body stores the extra calories as body fat. Even a fat-free food can have a lot of calories that eventually will contribute and can be stored as excess body fat.</p>
<h2>Why does fat get all of the attention?</h2>
<p>Fat gets all of the attention for many good reasons. Consider these facts:</p>
<ul>
<li>Some fats can raise cholesterol levels in the blood. A high cholesterol level is a leading risk factor for heart disease.</li>
<li>Some fatty foods (such as bacon, sausage, and potato chips) often have higher calories with fewer vitamins and minerals than low-fat other foods. (Note: Protein sources, especially red meat and dairy products, often contain fat. Good, low-fat sources of protein include lean meat, fish, poultry without skin, beans, lentils, tofu, low-fat yogurt, low-fat milk, and low-fat cottage cheese, and tuna fish packed in water.)</li>
<li>Fat has about twice as many calories per gram as carbohydrates and proteins. A gram of fat has about 9 calories, while a gram of carbohydrate or protein has about 4 calories. In other words, you could eat twice as much carbohydrates or proteins as fat for the same amount of calories.</li>
</ul>
<h2>Will I lose weight if I eat low-fat foods?</h2>
<p>It&#8217;s true that a diet high in fat can lead to weight gain. But it takes more than just eating low-fat foods to lose weight. You must also watch how many calories you eat. Remember, extra calories even from fat-free and low-fat foods get stored in the body as body fat. Many times people replace high-fat foods for high-calorie foods, like sweets, and gain weight rather than lose weight.</p>
<p>To lose weight, you need to burn more calories than you eat. You can achieve this goal by eating less fat and fewer calories, and exercising. Exercise burns calories. (Consult with your health care provider before starting an exercise or diet program.)</p>
<h2>How much fat should I eat?</h2>
<p>A low-fat style of eating is important for maintaining a healthy weight and preventing heart disease. The American Heart Association recommends limiting total calories from fat to less than 30 percent. That&#8217;s about 65 grams of fat or less a day if you eat 2,000 calories a day.</p>
<h2>How can I know how much fat I am eating?</h2>
<ul>
<li>Read nutrition labels on food packages. Nutrition labels show the number of grams of fat per serving. Compare this number to your ‘budgeted’ amount of fat for the day. Food labels They also show the daily percentage of fat provided in each serving. In other words, if the daily percentage of fat per serving is 18%, each serving provides 18% of the total fat you should eat for the day. Choose a brand that has a lower fat percentage. (The daily percentage value is based on a number of calories listed on the nutrition label, usually 2,000. Your calorie needs may be higher or lower.)</li>
<li>Learn about the foods you eat. Fat and calorie listings for individual foods can be found in nutrition books at your local library and on food packages.</li>
</ul>
<h2>How many grams of fat should I eat each day?</h2>
<table class="dataTable" style="width: 100%; text-align: left;" border="0">
<colgroup></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th scope="col">If you eat this many calories daily:</th>
<th scope="col">Eat no more than this many fat grams daily (based on 30% calories from fat)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td width="50%">1,200</td>
<td width="50%">40</td>
</tr>
<tr class="even">
<td>1,500</td>
<td>50</td>
</tr>
<tr class="odd">
<td height="31">1,800</td>
<td>60</td>
</tr>
<tr class="even">
<td>2,000</td>
<td>70</td>
</tr>
<tr class="odd">
<td>2,200</td>
<td>80</td>
</tr>
<tr class="even">
<td>2,500</td>
<td>90</td>
</tr>
</tbody>
</table>
<h5>Label claims</h5>
<p>Some food labels make claims such as &#8220;low cholesterol&#8221; or &#8220;low-fat.&#8221; These claims can only be used if a food meets strict government definitions. Here are some meanings:</p>
<table class="dataTable" style="width: 100%; text-align: left;" border="0">
<colgroup></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th scope="col">Label claim</th>
<th scope="col">Definition (per serving size)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td width="50%">Fat-free or sugar-free</td>
<td width="50%">Less than 0.5 grams of fat or sugar</td>
</tr>
<tr class="even">
<td>Low-fat</td>
<td>3 grams or less of fat</td>
</tr>
<tr class="odd">
<td height="31">Reduced fat or reduced sugar</td>
<td>At least 25% less fat or sugar</td>
</tr>
<tr class="even">
<td>Cholesterol-free</td>
<td>Less than 2 milligrams of cholesterol and 2 grams or less of saturated fat</td>
</tr>
<tr class="odd">
<td>Reduced cholesterol</td>
<td>At least 25% less cholesterol and 2 grams or less of saturated fat</td>
</tr>
<tr class="even">
<td>Calorie-free</td>
<td>Less than 5 calories</td>
</tr>
<tr class="odd">
<td>Low calorie</td>
<td>40 calories or less</td>
</tr>
<tr class="even">
<td>Light or lite</td>
<td>One-third fewer calories or 50% less fat; if more than half the calories come from fat, fat content must be reduced by 50% or more</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/what-is-the-difference-between-calories-and-fat/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WCF beginner&#8217;s guide</title>
		<link>http://www.webdoubt.com/wcf-beginners-guide/</link>
		<comments>http://www.webdoubt.com/wcf-beginners-guide/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 00:06:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.webdoubt.com/?p=47</guid>
		<description><![CDATA[1. Create a WCF Service Library project
2. Create an entity object class .cs.
3. Annotate entity class with [DataContract] attribute.
4. Annotate fields (from class above) you want in the contract with [DataMember] attribute.
5. Next, create a IService.cs interface that has the operations that can be performed.
6. Annotate with [ServiceContract] attribute.
7. Annotate methods with [OperationContract] attribute.
8. Create [...]]]></description>
			<content:encoded><![CDATA[<p>1. Create a WCF Service Library project<br />
2. Create an entity object class <entity>.cs.<br />
3. Annotate entity class with [DataContract] attribute.<br />
4. Annotate fields (from class above) you want in the contract with [DataMember] attribute.<br />
5. Next, create a I<entity>Service.cs interface that has the operations that can be performed.<br />
6. Annotate with [ServiceContract] attribute.<br />
7. Annotate methods with [OperationContract] attribute.<br />
8. Create <entity>Service.cs class to hold the actual implementation of the interface above.<br />
9. Annotate with [ServiceBehaviour] attribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/wcf-beginners-guide/feed/</wfw:commentRss>
		</item>
		<item>
		<title>.NET Streams cheatsheet</title>
		<link>http://www.webdoubt.com/net-streams-cheatsheet/</link>
		<comments>http://www.webdoubt.com/net-streams-cheatsheet/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 23:17:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET C#]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.webdoubt.com/?p=46</guid>
		<description><![CDATA[A summary of streams in .NET.
TextReader [abstract]
&#8212;&#8211;&#62; StringReader
&#8212;&#8211;&#62; StreamReader
TextWriter [abstract]
&#8212;&#8211;&#62; StringWriter (uses underlying StringBuilder)
&#8212;&#8211;&#62; StreamWriter
]]></description>
			<content:encoded><![CDATA[<p>A summary of streams in .NET.</p>
<p>TextReader [abstract]<br />
&#8212;&#8211;&gt; StringReader<br />
&#8212;&#8211;&gt; StreamReader</p>
<p>TextWriter [abstract]<br />
&#8212;&#8211;&gt; StringWriter (uses underlying StringBuilder)<br />
&#8212;&#8211;&gt; StreamWriter</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/net-streams-cheatsheet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Anonymous BitTorrent / Anonymous Internet Surfing</title>
		<link>http://www.webdoubt.com/anonymous-bittorrent-anonymous-internet-surfing/</link>
		<comments>http://www.webdoubt.com/anonymous-bittorrent-anonymous-internet-surfing/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 00:29:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Privacy]]></category>

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=45</guid>
		<description><![CDATA[A list of software applications, tools and utilities for anonymous bittorrent and anonymous web surfing.

Anomos
&#8220;Anomos is a pseudonymous, encrypted multi-peer-to-peer file distribution protocol. It is based on the peer/tracker concept of BitTorrent in combination with an onion routing anonymization layer, with the added benefit of end-to-end encryption. By combining these technologies, we have created a [...]]]></description>
			<content:encoded><![CDATA[<p>A list of software applications, tools and utilities for anonymous bittorrent and anonymous web surfing.</p>
<p><span id="more-45"></span></p>
<p><a href="http://anomos.info/" target="_blank">Anomos</a></p>
<p>&#8220;<strong>Anomos</strong> is a pseudonymous, encrypted multi-peer-to-peer file distribution protocol. It is based on the peer/tracker concept of BitTorrent in combination with an onion routing anonymization layer, with the added benefit of end-to-end encryption. By combining these technologies, we have created a platform where by no party outside of the trusted tracker will have any information about who a peer is or what they are downloading.&#8221;</p>
<p><a href="http://www.bitblinder.com/" target="_blank">BitBlinder</a></p>
<p>&#8220;Marketers, corporations, criminals, and governments all monitor your online activities.   Some even use filters to completely block your access to information.   BitBlinder is software that gives you back your online freedom.&#8221;</p>
<p><a href="http://www.i2p2.de/" target="_blank">I2P Anonymous Network</a></p>
<p>&#8220;I2P is an anonymizing network, offering a simple layer that identity-sensitive applications can use to securely communicate.  All data is wrapped with several layers of encryption, and the network is both distributed and dynamic, with no trusted parties.</p>
<p>Many applications are available that interface with I2P, including mail, peer-peer, IRC chat, and others.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/anonymous-bittorrent-anonymous-internet-surfing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ObjectDataSource : how to set insert / update parameters programmatically</title>
		<link>http://www.webdoubt.com/objectdatasource-how-to-set-insert-update-parameters-programmatically/</link>
		<comments>http://www.webdoubt.com/objectdatasource-how-to-set-insert-update-parameters-programmatically/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 23:02:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET C#]]></category>

		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.webdoubt.com/?p=44</guid>
		<description><![CDATA[Having begun programming with ASP.NET from its inception where you wrote your own solutions to common problems, I&#8217;ve found the introduction of ObjectDataSource objects and similar functionality a blessing and a curse. Although they can save a bit of coding I always find my self wasting lots of time trying to find which events I [...]]]></description>
			<content:encoded><![CDATA[<p>Having begun programming with ASP.NET from its inception where you wrote your own solutions to common problems, I&#8217;ve found the introduction of ObjectDataSource objects and similar functionality a blessing and a curse. Although they can save a bit of coding I always find my self wasting lots of time trying to find which events I should be performing certain tasks in. Trying to find how to do simple tasks such as setting insert or update parameters can often waste considerable amount of time.</p>
<p>To that end, I&#8217;ve written the following the &#8220;remind&#8221; myself of these simple tasks&#8230;</p>
<p><span id="more-44"></span></p>
<p>First, if you&#8217;re working with the ObjectDataSource using the DataObjectTypeName property (passing objects in the CRUD methods) the dictionaries passed to the inserting, updating and deleting events are read only by design. If you try to modify these values you will get a &#8220;OrderedDictionary is readonly and cannot be<br />
modified.&#8221; error. For example, you can&#8217;t access an InputParameter and modify it. You can however, access the InputParameter and modify the <strong>object it contains</strong>! For example in your ObjectDataSource_Updating method&#8230;</p>
<p>Location entity = (Location)e.InputParameters["entity"];<br />
entity.CityTownID = some_value;</p>
<p>If you&#8217;re not using DataObjectTypeName and are therefore not passing an entity object in your CRUD methods, then you can modify parameters in your ObjectDataSource inserting/updating methods. For example&#8230;</p>
<p>e.InputParameters["some_param"] = some_value;</p>
<p>Or if the parameter doesn&#8217;t exists&#8230;</p>
<p>ObjectDataSource1.UpdateParameters.Add(&#8221;some_param&#8221;, &#8220;some_value&#8221;);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/objectdatasource-how-to-set-insert-update-parameters-programmatically/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SQL Server Report Builder: how to access a TextBox value</title>
		<link>http://www.webdoubt.com/sql-server-report-builder-how-to-access-a-textbox-value/</link>
		<comments>http://www.webdoubt.com/sql-server-report-builder-how-to-access-a-textbox-value/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 02:32:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Report Builder]]></category>

		<category><![CDATA[Reporting Services]]></category>

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=43</guid>
		<description><![CDATA[I recently needed to access a TextBox value in an expression in one of my SQL Server Report Builder (SQL Reporting Services) reports recently, and found it surprisingly hard to find the answer).
ReportItems!tbxMyTextbox.Value
]]></description>
			<content:encoded><![CDATA[<p>I recently needed to access a TextBox value in an expression in one of my SQL Server Report Builder (SQL Reporting Services) reports recently, and found it surprisingly hard to find the answer).</p>
<p><span id="more-43"></span><strong>ReportItems!tbxMyTextbox.Value</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/sql-server-report-builder-how-to-access-a-textbox-value/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to create a masked textbox using JavaScript</title>
		<link>http://www.webdoubt.com/how-to-create-a-masked-textbox-using-javascript/</link>
		<comments>http://www.webdoubt.com/how-to-create-a-masked-textbox-using-javascript/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 06:19:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HTML]]></category>

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

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=42</guid>
		<description><![CDATA[This article demonstrates how to implement a masked input box or masked textbox using JavaScript. For example, let&#8217;s imagine you have a simple HTML form and want to restrict the user to enter on numbers in a Telephone number field. The following code will demonstrate how to to capture the keypress events of a form [...]]]></description>
			<content:encoded><![CDATA[<p>This article demonstrates how to implement a masked input box or masked textbox using JavaScript. For example, let&#8217;s imagine you have a simple HTML form and want to restrict the user to enter on numbers in a Telephone number field. The following code will demonstrate how to to capture the keypress events of a form element (eg. your Telephone input textbox) and to restrict which keys can be pressed.</p>
<p><span id="more-42"></span></p>
<pre class=code>
<code>&lt;script&gt;
        function maskedTextbox(evt) {
            var e = evt || window.event;
            var pK = evt.which || e.keyCode;
            var keyPressed = String.fromCharCode(pK);
            var reDigit = /^\d$/;
            var reCTRLChars = /[\x63\x78\x76\x7A]/; // Non-IE: cut, paste, etc. IE lets CTRL operations through.
            var reAllowedCodes = /[\x00\x08\x23\x24\x25\x26\x27\x28\x2D\x2E]/; // arrow keys, ins, del, hom, end, bspace
            if (reCTRLChars.test(keyPressed) || reAllowedCodes.test(keyPressed) || reDigit.test(keyPressed)) {
                return true;
            }
            return false;
        }
&lt;/script&gt;

&lt;-- Normal HTML example --&gt;
&lt;input type="text" onkeypress="return maskedTextbox(event);" /&gt;

&lt;-- ASP.NET C# example --&gt;
&lt;asp:TextBox ID="txtEmail" onkeypress="return maskedTextbox(event);" runat="server" /&gt;</code>
</pre>
<p>The example demonstrates restricting input to an HTML form element by capturing the onkeypress event. The javascript function will check which key was pressed and return true or false based on whether the keypress is allowed or not. The particular example restricts input to only numbers (ie. 0 to 9). However, there are some other characters we must allow through - INSERT, HOME, DELETE, END, BACKSPACE, and the ARROW keys.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/how-to-create-a-masked-textbox-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Random number generator for JavaScript</title>
		<link>http://www.webdoubt.com/random-number-generator-javascript/</link>
		<comments>http://www.webdoubt.com/random-number-generator-javascript/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 02:42:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.webdoubt.com/?p=41</guid>
		<description><![CDATA[Need to know how to generate a random number in JavaScript? The following code will do the job. There are a lot of articles on the internet explaining how to generate a random number between 0 and 10 (for example), but not so many explaining how to generate a random number within a certain specified [...]]]></description>
			<content:encoded><![CDATA[<p>Need to know how to generate a random number in JavaScript? The following code will do the job. There are a lot of articles on the internet explaining how to generate a random number between 0 and 10 (for example), but not so many explaining how to generate a random number within a certain specified range. And of those solutions, some of these didn&#8217;t produce very random results. The solution below, I&#8217;ve tested with 10,000 repetitions and found that there was a good even distribution over all numbers in the specified range.<br />
<span id="more-41"></span></p>
<pre><code>// 'min' and 'max' are inclusive.
function randomNumber(min, max)
{
    return Math.floor((max + 1 - min) * Math.random() + min);
}

// Example: to select a random number between 5 and 20 (inclusive).
var num = randomNumber(5,20);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/random-number-generator-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to get the parts of a URL in ASP.NET</title>
		<link>http://www.webdoubt.com/how-to-get-the-components-of-a-url-in-aspnet/</link>
		<comments>http://www.webdoubt.com/how-to-get-the-components-of-a-url-in-aspnet/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 02:43:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET C#]]></category>

		<category><![CDATA[C#]]></category>

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=30</guid>
		<description><![CDATA[Every time I need to parse a URL or to extract parts of a URL in ASP.NET C# I can never remember what I did last time and need to refer to the documentation. So, in order to quickly answer the question &#8220;How can I get the elements of a URL in C#?&#8221;, I&#8217;ve made [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I need to parse a URL or to extract parts of a URL in ASP.NET C# I can never remember what I did last time and need to refer to the documentation. So, in order to quickly answer the question &#8220;How can I get the elements of a URL in C#?&#8221;, I&#8217;ve made this quick reference.<span id="more-30"></span></p>
<pre><code>Uri uri = new Uri("http://www.contoso.com:8080/catalog
/shownew.htm?date=today");
Response.Write("AbsoluteUri: " + uri.AbsoluteUri);
Response.Write("Scheme: " + uri.Scheme);
Response.Write("Host: " + uri.Host);
Response.Write("Port: " + uri.Port);
Response.Write("AbsolutePath: " + uri.AbsolutePath);
Response.Write("PathAndQuery: " + uri.PathAndQuery);
Response.Write("Query: " + uri.Query);
string[] segments = uri.Segments;
foreach (string s in segments)
{
    Response.Write("Segment: " + s);
}
Response.Write("Authority: " + uri.Authority);
Response.Write("HostNameType: " + uri.HostNameType.ToString());
Response.Write("IsDefaultPort: " + uri.IsDefaultPort.ToString());
Response.Write("IsFile: " + uri.IsFile.ToString());</code></pre>
<p>The output:</p>
<p>AbsoluteUri:  http://www.contoso.com:8080/catalog/shownew.htm?date=today<br />
Scheme:  http<br />
Host: www.contoso.com<br />
Port: 8080<br />
AbsolutePath:  /catalog/shownew.htm<br />
PathAndQuery: /catalog/shownew.htm?date=today<br />
Query:  ?date=today<br />
Segment: /<br />
Segment: catalog/<br />
Segment:  shownew.htm<br />
Authority: www.contoso.com:8080<br />
HostNameType:  Dns<br />
IsDefaultPort: False<br />
IsFile: False</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/how-to-get-the-components-of-a-url-in-aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SELECT DISTINCT and ORDER BY</title>
		<link>http://www.webdoubt.com/select-distinct-and-order-by-error/</link>
		<comments>http://www.webdoubt.com/select-distinct-and-order-by-error/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 02:52:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SQL Server]]></category>

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

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

		<guid isPermaLink="false">http://www.webdoubt.com/?p=29</guid>
		<description><![CDATA[ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
Recently discovered the above error (T-SQL, SQL Server) when trying to select DISTINCT rows for one set of columns while ordering the rows by another column.
Jeff Smith had a good explanation of why this occurs (article). In a nutshell, if you&#8217;re trying [...]]]></description>
			<content:encoded><![CDATA[<p><code style="color: #990000;">ORDER BY items must appear in the select list if SELECT DISTINCT is specified.</code></p>
<p>Recently discovered the above error (T-SQL, SQL Server) when trying to select DISTINCT rows for one set of columns while ordering the rows by another column.</p>
<p>Jeff Smith had a good explanation of why this occurs (<a href="http://weblogs.sqlteam.com/jeffs/archive/2007/12/13/select-distinct-order-by-error.aspx" target="_blank">article</a>). In a nutshell, if you&#8217;re trying to order your distinct results but the other column you are ordering by is NOT distinct, then how will SQL Server know which value to use for ordering?</p>
<p><span id="more-29"></span></p>
<p>The solution is to use a GROUP BY and aggregate function (eg. MAX or MIN) to achieve the same effect. So for example, we do a GROUP BY on our &#8220;distinct&#8221; columns: column1 and column2. Then we order the results by column3. However, we use an aggregate function (MAX in this example) to ensure SQL Server has a specific column3 value with which to sort by.</p>
<pre class=code>
<code>SELECT column1, column2
FROM tablename
GROUP BY column1, column2
ORDER BY MAX(column3)</code>
</pre>
<h2>DISTINCT and ORDER BY with 2 non-DISTINCT columns</h2>
<p>The above solution didn&#8217;t however provide a solution for my specific scenario. I infact had 2 non-distinct columns which I needed to deal with while still selecting distinct rows based on a different set of columns.</p>
<p>I had a [Rank] column by which I wanted to sort the results. The above solution would assist with that. However, I also had a non-distinct [ResultTypeID] column that I also wanted to return in my results. It didn&#8217;t matter which ResultTypeID I returned but I still wanted to return a value for this column. The solution? Again, another aggregate function&#8230;</p>
<pre class=code>
<code>SELECT MIN(ResultTypeID), column1, column2
FROM tablename
GROUP BY column1, column2
ORDER BY MAX(Rank)</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webdoubt.com/select-distinct-and-order-by-error/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
