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

<channel>
	<title>SQL Date Parameter &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/sql-date-parameter/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Fri, 17 Jul 2015 12:26:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>SQL Date Parameter &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SqlDateTime Overflow, Must be between Error</title>
		<link>https://sibeeshpassion.com/sqldatetime-overflow-must-be-between-error/</link>
					<comments>https://sibeeshpassion.com/sqldatetime-overflow-must-be-between-error/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Fri, 05 Jun 2015 07:16:12 +0000</pubDate>
				<category><![CDATA[Q&A]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Date Parameter]]></category>
		<category><![CDATA[SQL Errors]]></category>
		<category><![CDATA[SQL Parameter Error]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=4482</guid>

					<description><![CDATA[Introduction Hi All, I hope you are fine. We all are using SQL parameter in our application right?Yeah it is a good way to restrict the Injections are hijacks. But still if you pass those parameters in the right way, you will face lots of problems. In this article I am going to share you such an Issue. I hope you will like it. Background Morning I was working in a grid control which editable, and I selected a row to edit and started editing. In a date field I edited the date and clicked update button. I was expecting [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Hi All, I hope you are fine. We all are using SQL parameter in our application right?Yeah it is a good way to restrict the Injections are hijacks. But still if you pass those parameters in the right way, you will face lots of problems. In this article I am going to share you such an Issue. I hope you will like it.</p>
<p><strong>Background</strong></p>
<p>Morning I was working in a grid control which editable, and I selected a row to edit and started editing. In a date field I edited the date and clicked update button. I was expecting an output result as &#8220;Successfully updated&#8221;. But it didn&#8217;t happen. Instead it throws an error. <em>&#8220;SqlDateTime Overflow, Must be between&#8221;</em></p>
<p><strong>Using the code</strong></p>
<p>To resolve this issue, first you must understand the root cause for this. I was passing the parameters as follows.</p>
<p>[csharp]<br />
 SqlParameter[] myParam = new SqlParameter[3];<br />
            myParam[0] = new SqlParameter(&quot;@name&quot;, myObject.name);<br />
            myParam[1] = new SqlParameter(&quot;@ValidFrom&quot;, myObject.hjcValidFrom);<br />
            myParam[2] = new SqlParameter(&quot;@ValidTo&quot;, myObject.hjcValidTo);<br />
[/csharp]</p>
<p>When I run my application with above code, I got the following error.<br />
<img decoding="async" src="http://sibeeshpassion.com/Content/Images/sqldateerror.PNG" alt="" /></p>
<p><strong>So what is the fix/solution?</strong></p>
<p>I changed the parameter as follows. </p>
<p>[csharp]<br />
 SqlParameter[] myParam = new SqlParameter[3];<br />
            myParam[0] = new SqlParameter(&quot;@name&quot;, myObject.name);<br />
            myParam[1] = new SqlParameter(&quot;@ValidFrom&quot;, myObject.hjcValidFrom.ToString(&quot;MM/dd/YYYY&quot;));<br />
            myParam[2] = new SqlParameter(&quot;@ValidTo&quot;, myObject.hjcValidTo.ToString(&quot;MM/dd/YYYY&quot;));<br />
[/csharp]</p>
<p>That solved the issue. Simple right?</p>
<p><strong>Some other case</strong></p>
<p>There are dome other cases you may get this error if you use the codes as follows.<br />
[csharp]<br />
 SqlParameter[] myParam = new SqlParameter[3];<br />
            DateTime myDate=new DateTime();<br />
            myParam[0] = new SqlParameter(&quot;@name&quot;, myObject.name);<br />
            myParam[1] = new SqlParameter(&quot;@ValidFrom&quot;, myDate);<br />
            myParam[2] = new SqlParameter(&quot;@ValidTo&quot;, myDate);<br />
[/csharp]</p>
<p>What you have to do all to fix this issue is just take the now property value from your date time object and pass it your parameter.</p>
<p>[csharp]<br />
 SqlParameter[] myParam = new SqlParameter[3];<br />
            DateTime myDate = DateTime.Now;<br />
            myParam[0] = new SqlParameter(&quot;@name&quot;, myObject.name);<br />
            myParam[1] = new SqlParameter(&quot;@ValidFrom&quot;, myDate);<br />
            myParam[2] = new SqlParameter(&quot;@ValidTo&quot;, myDate);<br />
[/csharp]</p>
<p><strong>Conclusion </strong></p>
<p>I hope you enjoyed reading and found this useful. Please share me your valuable feedback. For me it matters a lot.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/sqldatetime-overflow-must-be-between-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
