<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>.NET Diary</title>
	<atom:link href="http://dotnetdiary.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotnetdiary.wordpress.com</link>
	<description>...your diary...your learnings</description>
	<lastBuildDate>Fri, 20 Nov 2009 04:24:14 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dotnetdiary.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/3dbf5535b366e731f635d8c26ddf763b?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>.NET Diary</title>
		<link>http://dotnetdiary.wordpress.com</link>
	</image>
			<item>
		<title>Error: The type &#8216;YourType, YourAssembly&#8217;, provided as the Service attribute value in the ServiceHost directive could not be found &#8211; Problem while using WCF</title>
		<link>http://dotnetdiary.wordpress.com/2009/11/20/error-the-type-yourtype-yourassembly-provided-as-the-service-attribute-value-in-the-servicehost-directive-could-not-be-found-problem-while-using-wcf/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/11/20/error-the-type-yourtype-yourassembly-provided-as-the-service-attribute-value-in-the-servicehost-directive-could-not-be-found-problem-while-using-wcf/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 04:13:19 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=117</guid>
		<description><![CDATA[
Error lied in ServiceIHaveMade.svc file. Need to implement the name change from ‘Service1’ to ‘ServiceIHaveMade’ here too along with the web.config file.
Before:
&#60;%@ ServiceHost Language="C#" Debug="true" Service="WcfService_Learn.Service1" CodeBehind="ServiceIHaveMade.svc.cs" %&#62;
After:
&#60;%@ ServiceHost Language="C#" Debug="true" Service="WcfService_Learn.ServiceIHaveMade" CodeBehind="ServiceIHaveMade.svc.cs" %&#62;
 
Web.config(partial)
&#60;system.serviceModel&#62;

       &#60;services&#62;

              &#60;service name="WcfService_Learn.ServiceIHaveMade" behaviorConfiguration="WcfService_Learn.ServiceIHaveMadeBehavior"&#62;

              &#60;!-- Service Endpoints --&#62;

              &#60;endpoint address="" binding="wsHttpBinding" contract="WcfService_Learn.IService1"&#62;

              &#60;!-- Upon deployment, the following identity element should be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=117&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://dotnetdiary.files.wordpress.com/2009/11/the-type.gif"><img class="alignnone size-medium wp-image-118" title="Error: The type 'YourType, YourAssembly', provided as the Service attribute value in the ServiceHost directive could not be found. Problem faced while creating WCF Service." src="http://dotnetdiary.files.wordpress.com/2009/11/the-type.gif?w=300&#038;h=240" alt="" width="300" height="240" /></a></p>
<p>Error lied in <strong>ServiceIHaveMade.svc</strong> file. Need to implement the name change from ‘Service1’ to ‘ServiceIHaveMade’ here too along with the <strong>web.config</strong> file.</p>
<pre><strong><span style="text-decoration:underline;">Before:</span></strong>
&lt;%@ ServiceHost Language="C#" Debug="true" Service="WcfService_Learn.Service1" CodeBehind="ServiceIHaveMade.svc.cs" %&gt;
<strong><span style="text-decoration:underline;">After:</span></strong>
&lt;%@ ServiceHost Language="C#" Debug="true" Service="WcfService_Learn.ServiceIHaveMade" CodeBehind="ServiceIHaveMade.svc.cs" %&gt;
 </pre>
<h1>Web.config(partial)</h1>
<pre>&lt;system.serviceModel&gt;

       &lt;services&gt;

              &lt;service name="WcfService_Learn.ServiceIHaveMade" behaviorConfiguration="WcfService_Learn.ServiceIHaveMadeBehavior"&gt;

              &lt;!-- Service Endpoints --&gt;

              &lt;endpoint address="" binding="wsHttpBinding" contract="WcfService_Learn.IService1"&gt;

              &lt;!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity automatically. --&gt;

                     &lt;identity&gt;

                           &lt;dns value="localhost"/&gt;

                     &lt;/identity&gt;

              &lt;/endpoint&gt;

              &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;

              &lt;/service&gt;

       &lt;/services&gt;

       &lt;behaviors&gt;

              &lt;serviceBehaviors&gt;

              &lt;behavior name="WcfService_Learn.ServiceIHaveMadeBehavior"&gt;

              &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;

                     &lt;serviceMetadata httpGetEnabled="true"/&gt;

                     &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;

                     &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;

              &lt;/behavior&gt;

              &lt;/serviceBehaviors&gt;

       &lt;/behaviors&gt;

&lt;/system.serviceModel&gt;</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=117&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/11/20/error-the-type-yourtype-yourassembly-provided-as-the-service-attribute-value-in-the-servicehost-directive-could-not-be-found-problem-while-using-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>

		<media:content url="http://dotnetdiary.files.wordpress.com/2009/11/the-type.gif?w=300" medium="image">
			<media:title type="html">Error: The type 'YourType, YourAssembly', provided as the Service attribute value in the ServiceHost directive could not be found. Problem faced while creating WCF Service.</media:title>
		</media:content>
	</item>
		<item>
		<title>Generics</title>
		<link>http://dotnetdiary.wordpress.com/2009/11/03/generics/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/11/03/generics/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 08:55:09 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=111</guid>
		<description><![CDATA[Generics are a new feature in version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=111&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Generics are a <strong>new feature in version 2.0</strong> of the C# language and the common language runtime (CLR). Generics <strong>introduce</strong> to the .NET Framework the <strong>concept of type parameters</strong>, which make it <strong>possible to design classes and methods</strong> that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations, as shown here:</p>
<p>C#</p>
<pre>// Declare the generic class
public class GenericList&lt;T&gt;
{
    void Add(T input) { }
}
class TestGenericList
{
    private class ExampleClass { }
    static void Main()
    {
        // Declare a list of type int
        GenericList&lt;int&gt; list1 = new GenericList&lt;int&gt;();

        // Declare a list of type string
        GenericList&lt;string&gt; list2 = new GenericList&lt;string&gt;();

        // Declare a list of type ExampleClass
        GenericList&lt;ExampleClass&gt; list3 = new GenericList&lt;ExampleClass&gt;();
    }
}</pre>
<ul>
<li>Use generic types to <strong>maximize code reuse</strong>, type safety, and performance.</li>
<li>The most common use of generics is to create collection classes.</li>
<li>The .NET Framework class library contains several new generic collection classes in the <a href="http://msdn.microsoft.com/en-us/library/system.collections.generic(VS.80).aspx">System.Collections.Generic</a> namespace. These should be used whenever possible in place of classes such as <a href="http://msdn.microsoft.com/en-us/library/system.collections.arraylist(VS.80).aspx">ArrayList</a> in the <a href="http://msdn.microsoft.com/en-us/library/system.collections(VS.80).aspx">System.Collections</a> namespace.</li>
<li>You can create your own <strong>generic</strong> <strong>interfaces</strong>, <strong>classes</strong>, <strong>methods</strong>, <strong>events</strong> and <strong>delegates</strong>.</li>
<li>Generic classes may be constrained to enable access to methods on particular data types.</li>
<li>Information on the types used in a generic data type may be obtained at run-time by means of reflection.</li>
</ul>
<p>//For Interfaces<br />
interface IComparable &lt;T&gt;<br />
//for structs<br />
struct HashBucket &lt;K,D&gt;<br />
//for methods<br />
static void Reverse &lt;T&gt; (T[] arr)<br />
//for delegates<br />
delegate void Action &lt;T&gt; (T arg)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=111&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/11/03/generics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>Strongly TYPED &amp; Loosely TYPED</title>
		<link>http://dotnetdiary.wordpress.com/2009/11/03/strongly-typed-loosely-typed/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/11/03/strongly-typed-loosely-typed/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 08:49:27 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=108</guid>
		<description><![CDATA[Definition: A strongly typed programming languages is one that requires the type of a variable to be explicitly stated. C is a strongly typed language. You must declare the type of data a variable will store for C to interpret it:
int myVariable;
myVariable = 25;
Perl is a loosely typed language. There is no need to declare [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=108&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Definition: </strong>A <strong>strongly typed programming languages</strong> is one <strong>that requires the type of a variable to be explicitly stated</strong>. C is a strongly typed language. You must declare the <em>type</em> of data a variable will store for C to interpret it:</p>
<p>int myVariable;<br />
myVariable = 25;</p>
<p>Perl is a <a href="http://perl.about.com/od/programmingglossary/g/looselytyped.htm">loosely typed</a> language. There is <strong>no need to declare the variable type before using it</strong>:</p>
<p>$myVariable = 25;<br />
$myVariable = &#8220;A String.&#8221;;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=108&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/11/03/strongly-typed-loosely-typed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>Basic dode to fetch data from sql server using select statement and put it in dataset using dataadapter</title>
		<link>http://dotnetdiary.wordpress.com/2009/11/03/basic-dode-to-fetch-data-from-sql-server-using-select-statement-and-put-it-in-dataset-using-dataadapter/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/11/03/basic-dode-to-fetch-data-from-sql-server-using-select-statement-and-put-it-in-dataset-using-dataadapter/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 08:42:07 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=104</guid>
		<description><![CDATA[System.Data.SqlClient.SqlConnection objConnection;

System.Data.DataSet objDataSet = new DataSet();

System.Data.SqlClient.SqlDataAdapter objDataAdapter;

objConnection = new SqlConnection("data source=192.168.93.60; uid= tallyman; pwd= tallyman; database=Tallyman");

#region Either of these 2 works

//objDataAdapter = new SqlDataAdapter("Select top 5 id from accounts", "data source=192.168.93.60; uid= tallyman; pwd= tallyman; database=Tallyman");

objDataAdapter = new SqlDataAdapter("Select top 5 id from accounts", objConnection);

#endregion Either of these 2 works

objDataAdapter.Fill(objDataSet, "accountsData");

Console.Write(objDataSet.Tables["accountsData"].Rows.Count);

Console.Read();
     [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=104&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><pre style="text-align:left;">System.Data.SqlClient.SqlConnection objConnection;

System.Data.DataSet objDataSet = new DataSet();

System.Data.SqlClient.SqlDataAdapter objDataAdapter;

objConnection = new SqlConnection("data source=192.168.93.60; uid= tallyman; pwd= tallyman; database=Tallyman");

#region Either of these 2 works

//objDataAdapter = new SqlDataAdapter("Select top 5 id from accounts", "data source=192.168.93.60; uid= tallyman; pwd= tallyman; database=Tallyman");

objDataAdapter = new SqlDataAdapter("Select top 5 id from accounts", objConnection);

#endregion Either of these 2 works

objDataAdapter.Fill(objDataSet, "accountsData");

Console.Write(objDataSet.Tables["accountsData"].Rows.Count);

Console.Read();<strong></strong></pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=104&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/11/03/basic-dode-to-fetch-data-from-sql-server-using-select-statement-and-put-it-in-dataset-using-dataadapter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>DropDown List With HardCoded Values with Default Selected a value</title>
		<link>http://dotnetdiary.wordpress.com/2009/10/28/dropdown-list-with-hardcoded-values-with-default-selected-a-value/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/10/28/dropdown-list-with-hardcoded-values-with-default-selected-a-value/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 10:41:42 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=99</guid>
		<description><![CDATA[There are two ways:
 
Way 1:
In aspx file:
     &#60;td style=&#8221;width: 90px; height: 56px;&#8221; valign=&#8221;middle&#8221;&#62;
        &#60;asp:DropDownList ID=&#8221;ddlTime&#8221; runat=&#8221;server&#8221; Width=&#8221;131px&#8221; onchange=&#8221;clickClient();&#8221;  Height=&#8221;19px&#8221;&#62;
&#60;/asp:DropDownList&#62;
     &#60;/td&#62;
In aspx.CS file:
    public static void PopulateDdlTime(DropDownList ddlTime)
    {
        ddlTime.Items.Add(new ListItem(&#8220;12:00AM–08:00AM&#8221;, &#8220;1200AM0800AM&#8221;));
        ddlTime.Items.Add(new ListItem(&#8220;08:00AM–04:00PM&#8221;, &#8220;0800AM0400PM&#8221;));
        ddlTime.Items.Add(new ListItem(DRISInternatiolization.DRISInternatiolization.GetLabelText(&#8220;464&#8243;), &#8220;Customize&#8221;));
        ddlTime.SelectedValue = &#8220;0800AM0400PM&#8221;;
    }
protected void Page_Load(object sender, EventArgs e)
       {
PopulateDdlTime(ddlTime);
……
……
}
Way 2:
In aspx file:
&#60;td style=&#8221;width: 90px; height: 56px;&#8221; valign=&#8221;middle&#8221;&#62;
    [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=99&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong><span style="text-decoration:underline;">There are two ways:</span></strong></p>
<p><strong><span style="text-decoration:underline;"> </span></strong></p>
<p><strong><span style="text-decoration:underline;">Way 1:</span></strong></p>
<p><strong><span style="text-decoration:underline;">In aspx file:</span></strong></p>
<p>     &lt;td style=&#8221;width: 90px; height: 56px;&#8221; valign=&#8221;middle&#8221;&gt;</p>
<p>        &lt;asp:DropDownList ID=&#8221;ddlTime&#8221; runat=&#8221;server&#8221; Width=&#8221;131px&#8221; onchange=&#8221;clickClient();&#8221;  Height=&#8221;19px&#8221;&gt;</p>
<p>&lt;/asp:DropDownList&gt;</p>
<p>     &lt;/td&gt;</p>
<p><strong><span style="text-decoration:underline;">In aspx.CS file:</span></strong></p>
<p>    public static void PopulateDdlTime(DropDownList ddlTime)</p>
<p>    {</p>
<p>        ddlTime.Items.Add(new ListItem(&#8220;12:00AM–08:00AM&#8221;, &#8220;1200AM0800AM&#8221;));</p>
<p>        ddlTime.Items.Add(new ListItem(&#8220;08:00AM–04:00PM&#8221;, &#8220;0800AM0400PM&#8221;));</p>
<p>        ddlTime.Items.Add(new ListItem(DRISInternatiolization.DRISInternatiolization.GetLabelText(&#8220;464&#8243;), &#8220;Customize&#8221;));</p>
<p>        ddlTime.SelectedValue = &#8220;0800AM0400PM&#8221;;</p>
<p>    }</p>
<p>protected void Page_Load(object sender, EventArgs e)</p>
<p>       {</p>
<p>PopulateDdlTime(ddlTime);</p>
<p>……</p>
<p>……</p>
<p>}</p>
<p><strong><span style="text-decoration:underline;">Way 2:</span></strong></p>
<p><strong><span style="text-decoration:underline;">In aspx file:</span></strong></p>
<p>&lt;td style=&#8221;width: 90px; height: 56px;&#8221; valign=&#8221;middle&#8221;&gt;</p>
<p>    &lt;asp:DropDownList ID=&#8221;ddlTime&#8221; runat=&#8221;server&#8221; Width=&#8221;131px&#8221; onchange=&#8221;clickClient();&#8221; Height=&#8221;19px&#8221;&gt;</p>
<p>                  &lt;asp:ListItem Value=&#8221;1200AM0800AM&#8221;&gt;12:00AM–08:00AM&lt;/asp:ListItem&gt;</p>
<p>                  &lt;asp:ListItem Value=&#8221;0800AM0400PM&#8221; Selected=&#8221;True&#8221;&gt;08:00AM–04:00PM&lt;/asp:ListItem&gt;</p>
<p>                  &lt;asp:ListItem Value=&#8221;Customize&#8221;&gt;Customize…&lt;/asp:ListItem&gt;</p>
<p>    &lt;/asp:DropDownList&gt;</p>
<p>&lt;/td&gt;<strong></strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=99&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/10/28/dropdown-list-with-hardcoded-values-with-default-selected-a-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem: Cant delete after copying FileInfo  “The process cannot access the file  because it is being used by another process.”</title>
		<link>http://dotnetdiary.wordpress.com/2009/10/28/problem-cant-delete-after-copying-fileinfo-%e2%80%9cthe-process-cannot-access-the-file-because-it-is-being-used-by-another-process-%e2%80%9d/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/10/28/problem-cant-delete-after-copying-fileinfo-%e2%80%9cthe-process-cannot-access-the-file-because-it-is-being-used-by-another-process-%e2%80%9d/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 10:34:05 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=94</guid>
		<description><![CDATA[
Solution:
You might have not disposed while reading/writing.
Use either of these two:
1.
StreamWriter objStreamWriterUp = null;
TextReader objTextReaderUp = null;
try
{
using (objTextReaderUp = new StreamReader(sourceFilePath)) 
{
using (objStreamWriterUp 
= new StreamWriter(destiFilePath, !blIsFirstTimeCl))
{
//your code
}
}
}
catch (Exception ex)
{
throw;
}
finally
{
 
if (objStreamWriterUp != null)
{
                    objStreamWriterUp.Dispose();
}
       }
2.
StreamWriter objStreamWriterUp = null;
TextReader objTextReaderUp = null;
try
{
objTextReaderUp = new StreamReader(sourceFilePath);
objStreamWriterUp = new StreamWriter(destiFilePath, !blIsFirstTimeCl);
//your code
}
catch (Exception ex)
{
throw;
}
finally
{
 
if (objTextReaderUp != null)
{
objTextReaderUp.Dispose();
}
 
if (objStreamWriterUp != [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=94&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h1></h1>
<h1><span style="text-decoration:underline;">Solution:</span></h1>
<p>You might have not disposed while reading/writing.<br />
<strong>Use either of these two:</strong></p>
<p><strong>1.</strong></p>
<p><span style="font-size:9pt;color:#2b91af;font-family:'Courier New';">StreamWriter</span><span style="font-size:9pt;font-family:'Courier New';"> objStreamWriterUp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:#2b91af;line-height:115%;font-family:'Courier New';">TextReader</span><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> objTextReaderUp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">try</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;background:yellow;color:blue;font-family:'Courier New';">using</span><span style="font-size:9pt;background:yellow;font-family:'Courier New';"> (objTextReaderUp = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamReader</span>(sourceFilePath))</span><span style="font-size:9pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 .5in;"><span style="font-size:9pt;background:yellow;color:blue;line-height:115%;font-family:'Courier New';">using</span><span style="font-size:9pt;background:yellow;line-height:115%;font-family:'Courier New';"> (objStreamWriterUp </span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 1.5in;"><span style="font-size:9pt;background:yellow;line-height:115%;font-family:'Courier New';">= <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamWriter</span>(destiFilePath, !blIsFirstTimeCl))</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 1in;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 1in;"><span style="font-size:9pt;color:#00b050;line-height:115%;font-family:'Courier New';">//your code</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 1in;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 0 .5in;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:'Courier New';">catch</span><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">throw</span><span style="font-size:9pt;font-family:'Courier New';">;</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">finally</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:green;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">if</span><span style="font-size:9pt;font-family:'Courier New';"> (objStreamWriterUp != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">                    objStreamWriterUp.Dispose();</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">       }</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><strong><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">2.</span></strong></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:#2b91af;font-family:'Courier New';">StreamWriter</span><span style="font-size:9pt;font-family:'Courier New';"> objStreamWriterUp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:#2b91af;line-height:115%;font-family:'Courier New';">TextReader</span><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> objTextReaderUp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">try</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">objTextReaderUp = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamReader</span>(sourceFilePath);</span></p>
<p class="MsoNormal" style="margin:0 0 0 .5in;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">objStreamWriterUp = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamWriter</span>(destiFilePath, !blIsFirstTimeCl);</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0;"><span style="font-size:9pt;color:#00b050;line-height:115%;font-family:'Courier New';">//your code</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:'Courier New';">catch</span><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> (<span style="color:#2b91af;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">throw</span><span style="font-size:9pt;font-family:'Courier New';">;</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">finally</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:green;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">if</span><span style="font-size:9pt;font-family:'Courier New';"> (objTextReaderUp != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;background:yellow;font-family:'Courier New';">objTextReaderUp.Dispose();</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:'Courier New';">if</span><span style="font-size:9pt;font-family:'Courier New';"> (objStreamWriterUp != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0 0 0 .5in;"><span style="font-size:9pt;background:yellow;font-family:'Courier New';">objStreamWriterUp.Dispose();</span></p>
<p class="MsoNormal" style="text-indent:.5in;margin:0 0 10pt .5in;"><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">}</span></p>
<p><span style="font-size:9pt;line-height:115%;font-family:'Courier New';">       }</span></p>
<p><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> </span> </p>
<p><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"> </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=94&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/10/28/problem-cant-delete-after-copying-fileinfo-%e2%80%9cthe-process-cannot-access-the-file-because-it-is-being-used-by-another-process-%e2%80%9d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>ACID</title>
		<link>http://dotnetdiary.wordpress.com/2009/10/28/acid/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/10/28/acid/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 10:10:51 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=91</guid>
		<description><![CDATA[ACID (an acronymn for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved.

Atomicity states that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic.” If one part [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=91&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>ACID</strong> (an acronymn for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved.</p>
<ul>
<li><strong>Atomicity</strong> states that <span style="text-decoration:underline;">database modifications must follow an “all or nothing” rule</span>. Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is critical that the database management system maintain the atomic nature of transactions in spite of any DBMS, operating system or hardware failure.</li>
<li><strong>Consistency</strong> states that <span style="text-decoration:underline;">only valid data will be written to the database</span>. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. On the other hand, if a transaction successfully executes, it will take the database from one state that is consistent with the rules to another state that is also consistent with the rules.</li>
<li><strong>Isolation</strong> requires that <span style="text-decoration:underline;">multiple transactions occurring at the same time not impact each other’s execution</span>. For example, if Joe issues a transaction against a database at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe’s entire transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from reading intermediate data produced as a side effect of part of Mary’s transaction that will not eventually be committed to the database. Note that the isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.</li>
<li><strong>Durability</strong> ensures that any <span style="text-decoration:underline;">transaction committed to the database will not be lost</span>. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=91&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/10/28/acid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>DateTime Validation using Javascript</title>
		<link>http://dotnetdiary.wordpress.com/2009/01/21/datetime-validation-using-javascript/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/01/21/datetime-validation-using-javascript/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 10:51:57 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=83</guid>
		<description><![CDATA[function Check()
    {
        doOnOff(&#8216;off&#8217;);
        var dtStart = document.getElementById(&#8216;&#60;%=txtStartDate.ClientID%&#62;&#8217;).value;
           var dtEnd = document.getElementById(&#8216;&#60;%=txtEndDate.ClientID%&#62;&#8217;).value;
 
 
           var pos1=dtStart.indexOf(dtCh)
           var strDay1=dtStart.substring(pos1)
           var pos2=dtEnd.indexOf(dtCh)
           var strDay2=dtEnd.substring(pos2)
               if(pos1&#62;2)
               {
                     alert(&#8220;The date format should be : mm/dd/yyyy&#8221;);
                      return false;
               }
            else if (strDay1.length&#62;8 )
               {
                      alert(&#8220;The date format should be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=83&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">function</span><span style="font-size:8pt;font-family:&quot;"> Check()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span>doOnOff(<span style="color:maroon;">&#8216;off&#8217;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>     </span><span>   </span><span style="color:blue;">var</span> dtStart = document.getElementById(<span style="color:maroon;">&#8216;&lt;%=txtStartDate.ClientID%&gt;&#8217;</span>).value;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> dtEnd = document.getElementById(<span style="color:maroon;">&#8216;&lt;%=txtEndDate.ClientID%&gt;&#8217;</span>).value;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> pos1=dtStart.indexOf(dtCh)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> strDay1=dtStart.substring(pos1)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> pos2=dtEnd.indexOf(dtCh)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> strDay2=dtEnd.substring(pos2)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span><span style="color:blue;">if</span>(pos1&gt;2)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span>          </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (strDay1.length&gt;8 )</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span><span style="color:blue;">else</span> <span style="color:blue;">if</span>(pos2&gt;2 )</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span>          </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (strDay2.length&gt;8 )</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>        </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (dtEnd.length&gt;10)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>     </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>     </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (isDate(dtStart)==<span style="color:blue;">false</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>          </span><span>  </span>document.getElementById(<span style="color:maroon;">&#8216;&lt;%=txtStartDate.ClientID%&gt;&#8217;</span>).focus();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>           </span><span> </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (isDate(dtEnd)==<span style="color:blue;">false</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>             </span><span>   </span>document.getElementById(<span style="color:maroon;">&#8216;&lt;%=txtEndDate.ClientID%&gt;&#8217;</span>).focus();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>             </span><span> </span><span>  </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">else</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span>{<span> </span><span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>            </span><span style="color:green;">//check bigger</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>            </span><span style="color:blue;">if</span>(Date.parse(dtStart)&gt;0 &amp;&amp; Date.parse(dtEnd)&gt;0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                </span><span>     </span><span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                </span><span style="color:blue;">if</span> (Date.parse(dtStart) &gt; Date.parse(dtEnd))<span>     </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                     </span>{<span> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span>      </span><span>              </span></span><span style="font-size:8pt;font-family:&quot;"><span>   </span>alert(<span style="color:maroon;">&#8216;&lt;%=ShellUtility.GetMessageDetails(&#8220;1028&#8243;)%&gt;&#8217;</span>);<span> </span><span>                    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                        </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                       </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span> </span><span>                   </span><span style="color:blue;">else</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                            </span>{<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                            </span><span style="color:blue;">var</span> diff_date = Date.parse(dtEnd) &#8211; Date.parse(dtStart); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                            </span><span style="color:blue;">if</span>(diff_date &gt; 2592000000)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                            </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                    </span><span>            </span>alert(<span style="color:maroon;">&#8216;&lt;%=ShellUtility.GetMessageDetails(&#8220;1027&#8243;)%&gt;&#8217;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                                       </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                                    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                                </span><span style="color:blue;">else</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                                    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                   </span><span>                     </span><span style="color:blue;">return</span> <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                                    </span>}<span>    </span><span>        </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                            </span>} </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>               </span><span style="color:blue;">else</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                     </span>alert(<span style="color:maroon;">&#8216;&lt;%=ShellUtility.GetMessageDetails(&#8220;5027&#8243;)%&gt;&#8217;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                     </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>                    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>           </span>}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:8pt;line-height:115%;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:green;font-family:&quot;">//This Part is to check Date formattings</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">var</span> dtCh= <span style="color:maroon;">&#8220;/&#8221;</span>;<span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:green;font-family:&quot;">//<span>     </span>var constMinYear = 1900;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:green;font-family:&quot;">//<span>  </span>var constMaxYear = 2020;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:green;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">function</span> isInteger(s){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> i;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">for</span> (i = 0; i &lt; s.length; i++){<span>   </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:green;">// Check that current character is number.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">var</span> c = s.charAt(i);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">if</span> (((c &lt; <span style="color:maroon;">&#8220;0&#8243;</span>) || (c &gt; <span style="color:maroon;">&#8220;9&#8243;</span>))) <span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:green;">// All characters are numbers.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">return</span> <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>  </span><span>  </span><span style="color:blue;">function</span> stripCharsInBag(s, bag){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> i;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">var</span> returnString = <span style="color:maroon;">&#8220;&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:green;">// Search through string&#8217;s characters one by one.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:green;">// If character is not in bag, append to returnString.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">for</span> (i = 0; i &lt; s.length; i++){<span>   </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">var</span> c = s.charAt(i);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>            </span><span style="color:blue;">if</span> (bag.indexOf(c) == -1) returnString += c;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">return</span> returnString;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">function</span> daysInFebruary (year){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span> </span><span style="color:green;">// February has 29 days in any year evenly divisible by four,</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:green;">// EXCEPT for centurial years which are not also divisible by 400.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>        </span><span style="color:blue;">return</span> (((year % 4 == 0) &amp;&amp; ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">function</span> DaysArray(n) {</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">for</span> (<span style="color:blue;">var</span> i = 1; i &lt;= n; i++) {</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">this</span>[i] = 31;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">if</span> (i==4 || i==6 || i==9 || i==11) {<span style="color:blue;">this</span>[i] = 30;}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">if</span> (i==2) {<span style="color:blue;">this</span>[i] = 29;}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span>} </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">return</span> <span style="color:blue;">this</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">function</span> isDate(dtStr){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> daysInMonth = DaysArray(12)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> pos1=dtStr.indexOf(dtCh)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> pos2=dtStr.indexOf(dtCh,pos1+1)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> strMonth=dtStr.substring(0,pos1)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> strDay=dtStr.substring(pos1+1,pos2)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">var</span> strYear=dtStr.substring(pos2+1)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>strYr=strYear</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (strDay.charAt(0)==<span style="color:maroon;">&#8220;0&#8243;</span> &amp;&amp; strDay.length&gt;1) strDay=strDay.substring(1);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (strMonth.charAt(0)==<span style="color:maroon;">&#8220;0&#8243;</span> &amp;&amp; strMonth.length&gt;1) strMonth=strMonth.substring(1);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">for</span> (<span style="color:blue;">var</span> i = 1; i &lt;= 3; i++) {</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">if</span> (strYr.charAt(0)==<span style="color:maroon;">&#8220;0&#8243;</span> &amp;&amp; strYr.length&gt;1) strYr=strYr.substring(1);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>month=parseInt(strMonth);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>day=parseInt(strDay);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>year=parseInt(strYr);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (pos1==-1 || pos2==-1){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span>alert(<span style="color:maroon;">&#8220;The date format should be : mm/dd/yyyy&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (strMonth.length&lt;1 || month&lt;1 || month&gt;12){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span>alert(<span style="color:maroon;">&#8220;Please enter a valid month&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (strDay.length&lt;1 || day&lt;1 || day&gt;31 || (month==2 &amp;&amp; day&gt;daysInFebruary(year)) || day &gt; daysInMonth[month]){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span>alert(<span style="color:maroon;">&#8220;Please enter a valid day&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (strYear.length != 4 || year==0 || year&lt;constMinYear || year&gt;constMaxYear){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span>alert(<span style="color:maroon;">&#8220;Please enter a valid 4 digit year between &#8220;</span>+constMinYear+<span style="color:maroon;">&#8221; and &#8220;</span>+constMaxYear);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>    </span><span style="color:blue;">if</span> (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==<span style="color:blue;">false</span>){</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span>alert(<span style="color:maroon;">&#8220;Please enter a valid date&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">false</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span>   </span><span> </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>    </span><span style="color:blue;">return</span> <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:8pt;line-height:115%;font-family:&quot;"><span>    </span>}</span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=83&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/01/21/datetime-validation-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>
	</item>
		<item>
		<title>ERROR : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints</title>
		<link>http://dotnetdiary.wordpress.com/2009/01/21/error-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/01/21/error-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 10:42:55 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[All]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=77</guid>
		<description><![CDATA[ERROR : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=77&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div id="attachment_79" class="wp-caption alignnone" style="width: 460px"><a rel="attachment wp-att-79" href="http://dotnetdiary.wordpress.com/2009/01/21/error-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2/"><img class="size-full wp-image-79" title="failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2" src="http://dotnetdiary.files.wordpress.com/2009/01/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2.jpg?w=450&#038;h=203" alt="failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2" width="450" height="203" /></a><p class="wp-caption-text">failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2</p></div>
<p class="MsoNormal" style="margin:0 0 0 .25in;"><span style="font-size:8pt;line-height:115%;"><span style="font-family:Calibri;">1. Chek NULL in database-table and use ISNULL .</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt .25in;"><span style="font-size:8pt;line-height:115%;"><span style="font-family:Calibri;">2. If there is some column in DataCarrier where AllowDBNull is False, always select that column from SP level whether it is required or not.</span></span></p>
<div id="attachment_78" class="wp-caption alignnone" style="width: 431px"><a rel="attachment wp-att-78" href="http://dotnetdiary.wordpress.com/2009/01/21/error-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/"><img class="size-full wp-image-78" title="failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints" src="http://dotnetdiary.files.wordpress.com/2009/01/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints.jpg?w=421&#038;h=186" alt="failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints" width="421" height="186" /></a><p class="wp-caption-text">failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints</p></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=77&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/01/21/error-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>

		<media:content url="http://dotnetdiary.files.wordpress.com/2009/01/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2.jpg" medium="image">
			<media:title type="html">failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints-2</media:title>
		</media:content>

		<media:content url="http://dotnetdiary.files.wordpress.com/2009/01/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints.jpg" medium="image">
			<media:title type="html">failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL error : Conversion failed when converting datetime from character string</title>
		<link>http://dotnetdiary.wordpress.com/2009/01/21/sql-error-conversion-failed-when-converting-datetime-from-character-string/</link>
		<comments>http://dotnetdiary.wordpress.com/2009/01/21/sql-error-conversion-failed-when-converting-datetime-from-character-string/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 10:29:35 +0000</pubDate>
		<dc:creator>leoullas</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://dotnetdiary.wordpress.com/?p=69</guid>
		<description><![CDATA[ 
In case of two THEN conditions of the CASE statement reference expressions of different data types. In this case, SQL Server implicitly converts the data type for the entire CASE expression to the data type in the THEN clause that has the highest order of data-type precedence. (See the SQL Server Books Online (BOL) topic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=69&subd=dotnetdiary&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p> </p>
<div id="attachment_71" class="wp-caption alignnone" style="width: 460px"><a rel="attachment wp-att-71" href="http://dotnetdiary.wordpress.com/2009/01/21/sql-error-conversion-failed-when-converting-datetime-from-character-string/sql-error-conversion-failed-when-converting-datetime-from-character-string/"><img class="size-full wp-image-71" title="sql-error-conversion-failed-when-converting-datetime-from-character-string" src="http://dotnetdiary.files.wordpress.com/2009/01/sql-error-conversion-failed-when-converting-datetime-from-character-string.jpg?w=450&#038;h=360" alt="sql-error-conversion-failed-when-converting-datetime-from-character-string" width="450" height="360" /></a><p class="wp-caption-text">sql-error-conversion-failed-when-converting-datetime-from-character-string</p></div>
<p><span style="font-size:8pt;line-height:115%;font-family:&quot;">In case of two THEN conditions of the CASE statement reference expressions of different data types. In this case, SQL Server implicitly converts the data type for the entire CASE expression to the data type in the THEN clause that has the highest order of data-type precedence. (See the SQL Server Books Online (BOL) topic &#8220;Data Type Precedence.&#8221;) </span></p>
<p><span style="font-size:8pt;line-height:115%;font-family:&quot;"><span style="text-decoration:underline;">BEFORE:</span></span></p>
<div></div>
<p><span style="font-size:8pt;line-height:115%;font-family:&quot;"></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">declare</span><span style="font-size:8pt;font-family:&quot;"> @SortExpression <span style="color:blue;">varchar</span><span style="color:gray;">(</span>20<span style="color:gray;">)</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">set</span><span style="font-size:8pt;font-family:&quot;"> @SortExpression <span style="color:gray;">=</span><span style="color:red;">&#8216;OverSpeed&#8217;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:red;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">SELECT</span><span style="font-size:8pt;font-family:&quot;"><span>        </span>Journey_Id<span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Drv_ID<span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span>       </span>Journey_Start_Dt <span style="color:blue;">AS</span> <span style="color:red;">&#8216;StartDateTime&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Journey_End_Dt <span style="color:blue;">AS</span> <span style="color:red;">&#8216;EndDateTime&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Journey_Time_Sec <span style="color:blue;">AS</span> <span style="color:red;">&#8216;TotalTime&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Journey_Dest_Miles <span style="color:blue;">AS</span> <span style="color:red;">&#8216;TotalDistance&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Max_Speed_Mph <span style="color:blue;">AS</span> <span style="color:red;">&#8216;MAXSpeed&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>Brake_Flg <span style="color:blue;">AS</span> <span style="color:red;">&#8216;AggDriving&#8217;</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span>OverSpeed_Flg <span style="color:blue;">AS</span> <span style="color:red;">&#8216;OverSpeed&#8217;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">FROM</span><span style="font-size:8pt;font-family:&quot;"><span>         </span>DRIVER_JOURNEY_INFO <span style="color:blue;">AS</span> td</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">WHERE</span><span style="font-size:8pt;font-family:&quot;"><span>     </span><span style="color:gray;">(</span>Company_Id <span style="color:gray;">=</span> 9003<span style="color:gray;">)</span> <span style="color:gray;">AND</span> <span style="color:gray;">(</span>Drv_ID <span style="color:gray;">=</span> 2017<span style="color:gray;">)</span> <span style="color:gray;">AND</span> <span style="color:gray;">(</span>Journey_Start_Dt <span style="color:gray;">BETWEEN</span> <span style="color:red;">&#8216;08/01/2008&#8242;</span> <span style="color:gray;">AND</span> <span style="color:red;">&#8216;09/30/2008&#8242;</span><span style="color:gray;">)</span> <span style="color:gray;">AND</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                      </span><span style="color:gray;">(</span>Journey_End_Dt <span style="color:gray;">BETWEEN</span> <span style="color:red;">&#8216;08/01/2008&#8242;</span> <span style="color:gray;">AND</span> <span style="color:red;">&#8216;09/30/2008&#8242;</span><span style="color:gray;">)</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">ORDER</span><span style="font-size:8pt;font-family:&quot;"> <span style="color:blue;">BY</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span style="color:blue;">CASE</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;Journey_Id&#8217;</span> <span style="color:blue;">THEN</span> Journey_Id </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;StartDateTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_Start_Dt </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;EndDateTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_End_Dt </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TotalTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_Time_Sec </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TotalDistance&#8217;</span> <span style="color:blue;">THEN</span> Journey_Dest_Miles </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;MAXSpeed&#8217;</span> <span style="color:blue;">THEN</span> Max_Speed_Mph </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;AggDriving&#8217;</span> <span style="color:blue;">THEN</span> Brake_Flg </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>                     </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;OverSpeed&#8217;</span> <span style="color:blue;">THEN</span> OverSpeed_Flg </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span style="color:blue;">ELSE</span> Journey_Id </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>              </span><span style="color:blue;">END</span> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt .25in;"><span style="font-size:8pt;color:blue;line-height:115%;font-family:&quot;">DESC</span></p>
<p><span style="text-decoration:underline;">CORRECTED:</span></p>
<p> </p>
<p> </p>
<p></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">ORDER</span><span style="font-size:8pt;font-family:&quot;"> <span style="color:blue;">BY</span></span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:8pt;color:blue;font-family:&quot;">CASE</span><span style="font-size:8pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;Journey_Id&#8217;</span> <span style="color:blue;">THEN</span> Journey_Id<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;StartDateTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_Start_Dt<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;EndDateTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_End_Dt<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TotalTime&#8217;</span> <span style="color:blue;">THEN</span> Journey_Time_Sec<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TotalDistance&#8217;</span> <span style="color:blue;">THEN</span> Journey_Dest_Miles <span>                                 </span><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;MAXSpeed&#8217;</span> <span style="color:blue;">THEN</span> Max_Speed_Mph </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TAII&#8217;</span> <span style="color:blue;">THEN</span> <span style="color:gray;">(</span><span style="color:fuchsia;">CAST</span><span style="color:gray;">(</span>TAI_Time_Sec <span style="color:blue;">AS</span> <span style="color:blue;">DECIMAL</span><span style="color:gray;">(</span>18<span style="color:gray;">,</span>2<span style="color:gray;">))/</span>Journey_Time_Sec<span style="color:gray;">)*</span>10</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;TIP&#8217;</span> <span style="color:blue;">THEN</span> <span style="color:gray;">(</span><span style="color:fuchsia;">CAST</span><span style="color:gray;">(</span>TI_Time_Sec <span style="color:blue;">AS</span> <span style="color:blue;">DECIMAL</span><span style="color:gray;">(</span>18<span style="color:gray;">,</span>2<span style="color:gray;">))/</span>Journey_Time_Sec<span style="color:gray;">)*</span>100 </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8221;</span> <span style="color:blue;">THEN</span> Journey_Id </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">END</span><span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">DESC</span><span style="color:gray;">,</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:8pt;font-family:&quot;"><span>       </span><span style="color:blue;">CASE</span> <span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;AggDriving&#8217;</span> <span style="color:blue;">THEN</span> Brake_Flg <span style="color:blue;">END</span><span>  </span><span style="color:blue;">DESC</span><span style="color:gray;">,</span> </span></p>
<p class="MsoNormal" style="margin:0 0 0 .25in;"><span style="font-size:8pt;line-height:115%;font-family:&quot;"><span>   </span><span style="color:blue;">CASE</span> <span style="color:blue;">WHEN</span> @SortExpression <span style="color:gray;">=</span> <span style="color:red;">&#8216;OverSpeed&#8217;</span> <span style="color:blue;">THEN</span> OverSpeed_Flg <span style="color:blue;">END</span><span>  </span><span style="color:blue;">DESC</span></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dotnetdiary.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dotnetdiary.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dotnetdiary.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dotnetdiary.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dotnetdiary.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dotnetdiary.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dotnetdiary.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dotnetdiary.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dotnetdiary.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dotnetdiary.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dotnetdiary.wordpress.com&blog=6246462&post=69&subd=dotnetdiary&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dotnetdiary.wordpress.com/2009/01/21/sql-error-conversion-failed-when-converting-datetime-from-character-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51555e1fbaa7dbd9ea43030c46616d28?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">leoullas</media:title>
		</media:content>

		<media:content url="http://dotnetdiary.files.wordpress.com/2009/01/sql-error-conversion-failed-when-converting-datetime-from-character-string.jpg" medium="image">
			<media:title type="html">sql-error-conversion-failed-when-converting-datetime-from-character-string</media:title>
		</media:content>
	</item>
	</channel>
</rss>