<?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>Mudassar Ahmed Khan</title>
	<atom:link href="http://mudassarkhan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mudassarkhan.wordpress.com</link>
	<description>ASP.Net Blog</description>
	<lastBuildDate>Thu, 05 Mar 2009 06:10:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mudassarkhan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mudassar Ahmed Khan</title>
		<link>http://mudassarkhan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mudassarkhan.wordpress.com/osd.xml" title="Mudassar Ahmed Khan" />
	<atom:link rel='hub' href='http://mudassarkhan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Launch of WebSite</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/29/launch-of-website/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/29/launch-of-website/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 18:41:29 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=82</guid>
		<description><![CDATA[I have launched my website www.aspsnippets.com I have closed this blog and all the articles will be available on the site. Thanks all for the wonderful comments and appreciation.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=82&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have launched my website</p>
<p><a href="http://www.aspsnippets.com">www.aspsnippets.com</a></p>
<p>I have closed this blog and all the articles will be available on the site.</p>
<p>Thanks all for the wonderful comments and appreciation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=82&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/29/launch-of-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Email using VB</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/16/sending-email-using-vb/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/16/sending-email-using-vb/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 18:01:44 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Email using VB]]></category>
		<category><![CDATA[Send Email using VB]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[System.Net]]></category>
		<category><![CDATA[System.Net.Mail]]></category>
		<category><![CDATA[VB.Net Email]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=80</guid>
		<description><![CDATA[Here I have discussed Sending Mails using VB.Net   First Import these Name Spaces Imports System.Net Imports System.Net.Mail   See the function below Public Function SendEmail(ByVal strTo As String, ByVal strFrom As String, ByVal strSubject As String, ByVal strBody As String, ByVal strAttachmentPath As String, ByVal IsBodyHTML As Boolean) As Boolean           Dim arrToArray [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=80&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Here I have discussed Sending Mails using VB.Net</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">First Import these Name Spaces</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">Imports</span><span style="font-size:10pt;font-family:&quot;"> System.Net</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:&quot;">Imports</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"> System.Net.Mail</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">See the function below</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">Public</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Function</span> SendEmail(<span style="color:blue;">ByVal</span> strTo <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> strFrom <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> strSubject <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> strBody <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> strAttachmentPath <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> IsBodyHTML <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span>) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Dim</span> arrToArray <span style="color:blue;">As</span> <span style="color:blue;">String</span>()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Dim</span> splitter <span style="color:blue;">As</span> <span style="color:blue;">Char</span> = <span style="color:maroon;">&#8220;;&#8221;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:maroon;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">&#8216;Loop through the recepient list and separate them</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">&#8216;based on semi colon</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>arrToArray = strTo.Split(splitter)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Dim</span> mm <span style="color:blue;">As</span> MailMessage = <span style="color:blue;">New</span> MailMessage()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.From = <span style="color:blue;">New</span> MailAddress(strFrom)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.Subject = strSubject</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.Body = strBody</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;"><span>    </span>&#8216;True &#8211; HTML Body</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>   </span><span> </span><span style="color:green;">&#8216;False &#8211; Text Body</span></span><span style="font-size:10pt;font-family:&quot;"></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.IsBodyHtml = IsBodyHTML</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">&#8216;Add the recepient email Addresses</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">For</span> <span style="color:blue;">Each</span> s <span style="color:blue;">As</span> <span style="color:blue;">String</span> <span style="color:blue;">In</span> arrToArray</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm.To.Add(<span style="color:blue;">New</span> MailAddress(s))</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Next</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">&#8216;Add Attachment</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.Attachments.Add(<span style="color:blue;">New</span> Attachment(strAttachmentPath))</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Dim</span> smtp <span style="color:blue;">As</span> SmtpClient = <span style="color:blue;">New</span> SmtpClient()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Your SMTP Server</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Host = <span style="color:maroon;">&#8220;Your smtp server&#8221;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:maroon;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;SSL Settings depending on your Server</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.EnableSsl = <span style="color:blue;">True</span> / <span style="color:blue;">False</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Reply To Address (Optional)</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm.ReplyTo = <span style="color:blue;">New</span> MailAddress(<span style="color:maroon;">&#8220;your reply to email&#8221;</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Creadentials for the Server</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:blue;">Dim</span> NetworkCred <span style="color:blue;">As</span> NetworkCredential </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>=<span style="color:blue;">New</span> System.Net.NetworkCredential()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Your Email</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>NetworkCred.UserName = <span style="color:maroon;">&#8221; sender@abc.com&#8221;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:maroon;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Your Password</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>NetworkCred.Password = <span style="color:maroon;">&#8220;your password&#8221;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:maroon;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.UseDefaultCredentials = <span style="color:blue;">True</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Credentials = NetworkCred</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">&#8216;Port No of the Server </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Port = Your Port No <span style="color:green;">&#8216; Port No</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Send(mm)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Catch</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">Finally</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp = <span style="color:blue;">Nothing</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm = <span style="color:blue;">Nothing</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">End</span> <span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"><span>    </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">To call this function</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">Protected</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Sub</span> Button1_Click(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> <span style="color:blue;">Object</span>, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.EventArgs) <span style="color:blue;">Handles</span> Button1.Click</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">SendEmail(<span style="color:maroon;">&#8220;sender@abc.com&#8221;</span>, <span style="color:maroon;">&#8220;recepient@abc.com&#8221;</span>, <span style="color:maroon;">&#8220;Subject&#8221;</span>, </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:maroon;font-family:&quot;">&#8220;Body&#8221;</span><span style="font-size:10pt;font-family:&quot;">, <span style="color:maroon;">&#8220;C:\MyDoc.doc&#8221;</span>, <span style="color:blue;">True</span>)</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:&quot;">End</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Also these are the settings for sending email using Gmail</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Host &#8211; smtp.gmail.com</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">SSL – true</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Port No 465, 587 or just comment Port No</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">UserName – Gmail Email</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Password Gmail Password</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=80&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/16/sending-email-using-vb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Job Schedular SQL Server 2000</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/13/job-schedular-sql-server-2000/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/13/job-schedular-sql-server-2000/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 16:53:58 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Batch Job. Job Scheduling]]></category>
		<category><![CDATA[Schedular]]></category>
		<category><![CDATA[SQL Server 2000]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=69</guid>
		<description><![CDATA[  Here I am explaining how to create a Scheduled Batch Job in SQL Server 2000.     The Steps to Create a Batch Job in SQL Server 2000 are described below.      Open SQL Server Enterprise Manager. Expand the Management node.  Right Click Job from the Sub Nodes and Select New Job from the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=69&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;">  Here I am explaining how to create a Scheduled Batch Job in SQL Server 2000.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;">  The Steps to Create a Batch Job in SQL Server 2000 are described below.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 19.95pt;"> </p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"><span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> Open SQL Server Enterprise Manager. Expand the Management node.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span> </span>Right Click Job from the Sub Nodes and Select New Job from the context Menu.</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 19.95pt;"> </p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span><span style="font-size:10pt;font-family:Arial,sans-serif;">For details refer Figure 1.0</span></p>
<p> </p>
<p> </p>
<p><img class="aligncenter size-full wp-image-70" title="img14" src="http://mudassarkhan.files.wordpress.com/2009/01/img14.jpg?w=460" alt="img14"   /><span style="font-size:10pt;font-family:Arial,sans-serif;">Figure 1.0</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"><span></span></span> </p>
<p class="MsoNormal" style="margin:0 0 0 23.7pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;">In the General Tab, you will have Fill the following Information</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 44.05pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span>1.<span style="font:7pt 'Times New Roman';"> </span></span></span><span style="font-size:10pt;font-family:Arial,sans-serif;">Name of the Batch Job</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 44.05pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span>2.<span style="font:7pt 'Times New Roman';"> </span></span></span><span style="font-size:10pt;font-family:Arial,sans-serif;">Category of the Batch Job</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 44.05pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span>3.<span style="font:7pt 'Times New Roman';"> </span></span></span><span style="font-size:10pt;font-family:Arial,sans-serif;">Owner of the Batch Job</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 44.05pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span>4.<span style="font:7pt 'Times New Roman';"> </span></span></span><span style="font-size:10pt;font-family:Arial,sans-serif;">Description of the Batch Job. If any</span></p>
<p class="MsoNormal" style="margin:0 0 0 .5in;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0 0 0 .5in;"><span style="font-size:10pt;font-family:Arial,sans-serif;"></span><span style="font-size:10pt;font-family:Arial,sans-serif;">For Details refer Figure 2.0</span></p>
<p><img class="aligncenter size-full wp-image-71" title="img23" src="http://mudassarkhan.files.wordpress.com/2009/01/img23.jpg?w=460" alt="img23"   /><span style="font-size:10pt;font-family:Arial,sans-serif;">Figure 2.0</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="text-indent:-.75pt;margin:0 0 0 4.5pt;"> </p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"></span></p>
<p class="MsoNormal" style="text-indent:-.75pt;margin:0 0 0 4.5pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span> </span></span></p>
<p class="MsoNormal" style="text-indent:-.75pt;margin:0 0 0 9pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><span> </span>The second Tab on the New Job window is Steps. Here you have to Click on New Step which will open the New Job Step window. You will need to fill the following details.</span></p>
<p class="MsoNormal" style="text-indent:-.75pt;margin:0 0 0 4.5pt;"> </p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p> </p>
<p> </p>
<ol style="margin-top:0;" type="1">
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;">Step Name – Name of the Job Step</span></li>
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;">Type – Type of the step. Since its a Stored Procedure I have Selected TSQL.</span></li>
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;">Database – The Database on which the stored procedure or Query needs to run</span></li>
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;">Command – The SQL Query you want to execute.</span></li>
</ol>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;">    </span><span style="font-size:10pt;font-family:Arial,sans-serif;"><span> </span>For Details refer Figure 3.0</span></p>
<p><img class="aligncenter size-full wp-image-72" title="img32" src="http://mudassarkhan.files.wordpress.com/2009/01/img32.jpg?w=460" alt="img32"   /><span style="font-size:10pt;font-family:Arial,sans-serif;">Figure 3.0</span><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p><span style="font-size:10pt;font-family:Arial,sans-serif;"><span></span></span><span style="font-size:10pt;font-family:Arial,sans-serif;">For more details refer Figure 4.0</span></p>
<p class="MsoNormal" style="margin:0 0 0 4.5pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;">The Third Tab is for Scheduling the Batch Job. Click new a New Jon Schedule Window will open. In that Window, give name to the Job Schedule. And select Recurring Schedule Type since the job will run on daily basis.<span>  </span></span></p>
<p>  </p>
<p> </p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 21.55pt;"><span style="font-size:10pt;font-family:Arial,sans-serif;"><img class="aligncenter size-full wp-image-73" title="img43" src="http://mudassarkhan.files.wordpress.com/2009/01/img43.jpg?w=460" alt="img43"   /></span><span style="font-size:10pt;font-family:Arial,sans-serif;"><span style="font-size:10pt;font-family:Arial,sans-serif;">      Figure 4</span></span><img class="aligncenter size-full wp-image-75" title="img54" src="http://mudassarkhan.files.wordpress.com/2009/01/img54.jpg?w=460" alt="img54"   /></p>
<p> </p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> After you select Recurring Radio Button Click on Change Button. Set the Schedule Settings</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"> As given in Figure 5</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;"></span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 21.55pt;"> </p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 21.55pt;"> <span style="font-size:10pt;font-family:&quot;">Figure 5</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:&quot;">6. Finally, to delete a SQL Job you can do the following as depicted in<span>  </span>Figure 6</span></p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 21.55pt;"> </p>
<p class="MsoNormal" style="text-indent:-.25in;margin:0 0 0 21.55pt;"><img class="aligncenter size-full wp-image-76" title="img62" src="http://mudassarkhan.files.wordpress.com/2009/01/img62.jpg?w=460" alt="img62"   /><span style="font-size:10pt;font-family:&quot;">Figure 6</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial,sans-serif;">  When you click on New Job a Window will open. It has four Tabs. The First Tab is General</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=69&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/13/job-schedular-sql-server-2000/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img14.jpg" medium="image">
			<media:title type="html">img14</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img23.jpg" medium="image">
			<media:title type="html">img23</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img32.jpg" medium="image">
			<media:title type="html">img32</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img43.jpg" medium="image">
			<media:title type="html">img43</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img54.jpg" medium="image">
			<media:title type="html">img54</media:title>
		</media:content>

		<media:content url="http://mudassarkhan.files.wordpress.com/2009/01/img62.jpg" medium="image">
			<media:title type="html">img62</media:title>
		</media:content>
	</item>
		<item>
		<title>EXPORT DATA TO EXCEL ADO.NET</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/12/export-data-to-excel-adonet/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/12/export-data-to-excel-adonet/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 17:08:13 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[.nET]]></category>
		<category><![CDATA[ACE]]></category>
		<category><![CDATA[C# Excel]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Excel 2007]]></category>
		<category><![CDATA[Export To Excel]]></category>
		<category><![CDATA[insert data in Excel]]></category>
		<category><![CDATA[oledb]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=42</guid>
		<description><![CDATA[Here I will explain How to insert data in Excel files using ADO.Net First comes the Excel 97-2003 format (*.XLS) For this Microsoft OLEDB Jet Driver will be used. Below is the function to insert Data into Excel Sheet, just like you do in a Database.   Here’s the Mapping Database   &#60;&#8212;&#8212;&#8212;&#8212;&#8212;&#62;    Excel Sheet         &#60;&#8212;&#8212;&#8212;&#8212;&#8212;&#62;     [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=42&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Here I will explain How to insert data in Excel files using ADO.Net</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">First comes the Excel 97-2003 format (*.XLS)</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">For this Microsoft OLEDB Jet Driver will be used. Below is the function to insert Data into Excel Sheet,</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">just like you do in a Database. </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Here’s the Mapping</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Database<span>  </span><span> </span>&lt;&#8212;&#8212;&#8212;&#8212;&#8212;&gt;<span>   </span><span> </span>Excel</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Sheet <span>   </span><span>   </span><span>  </span>&lt;&#8212;&#8212;&#8212;&#8212;&#8212;&gt;<span>     </span>Table</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"> </p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Here’s the function for Excel 97-2003 Format</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span><span style="font-size:10pt;color:green;font-family:&quot;">//Add New Row To Excel 97-2003 File</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:teal;">Boolean</span> AddExcelRow(<span style="color:teal;">String</span> strFilePath) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">if</span><span style="font-size:10pt;font-family:&quot;"> (!<span style="color:teal;">File</span>.Exists(strFilePath)) <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:10pt;color:teal;font-family:&quot;">String</span><span style="font-size:10pt;font-family:&quot;"> strExcelConn = <span style="color:maroon;">&#8220;Provider=Microsoft.Jet.OLEDB.4.0;&#8221;</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">+ <span style="color:maroon;">&#8220;Data Source=&#8221;</span> + strFilePath + <span style="color:maroon;">&#8220;;&#8221;</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">+ <span style="color:maroon;">&#8220;Extended Properties=&#8217;Excel 8.0;HDR=Yes&#8217;&#8221;</span>; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">OleDbConnection</span><span style="font-size:10pt;font-family:&quot;"> connExcel = <span style="color:blue;">new</span> <span style="color:teal;">OleDbConnection</span>(strExcelConn); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">OleDbCommand</span><span style="font-size:10pt;font-family:&quot;"> cmdExcel = <span style="color:blue;">new</span> <span style="color:teal;">OleDbCommand</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">try</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>cmdExcel.Connection = connExcel;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:green;">//Check if the Sheet Exists</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>connExcel.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:teal;">DataTable</span> dtExcelSchema;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>dtExcelSchema = </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>connExcel.GetOleDbSchemaTable(<span style="color:teal;">OleDbSchemaGuid</span>.Tables, <span style="color:blue;">null</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>  </span><span>  </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:teal;">DataRow</span>[] dr = dtExcelSchema.Select(<span style="color:maroon;">&#8220;TABLE_NAME = &#8216;tblData&#8217;&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:green;">//if not Create the Sheet</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (dr == <span style="color:blue;">null</span> || dr.Length == 0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>cmdExcel.CommandText = <span style="color:maroon;">&#8220;CREATE TABLE [tblData]&#8220;</span> +</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>         </span><span style="color:maroon;">&#8220;(ID varchar(10), Name varchar(50));&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>cmdExcel.ExecuteNonQuery();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>connExcel.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:green;">//Add New Row to Excel File </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>cmdExcel.CommandText = <span style="color:maroon;">&#8220;INSERT INTO [tblData] (ID, Name)&#8221;</span> +</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:maroon;">&#8221; values (&#8217;1&#8242;, &#8216;MAK&#8217;)&#8221;</span>; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>cmdExcel.ExecuteNonQuery();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">catch</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">finally</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>cmdExcel.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>connExcel.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">To Insert Data in Excel 2007 (*.XLSX) OLEDB Jet will not work. For that you will have</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">to use the new Microsoft Ace Driver. Rest all will be the same as we did for Excel 97-2003 format.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Here’s the function</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;">//Add New Row To Excel 2007 File</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:teal;">Boolean</span> AddExcelRow2007(<span style="color:teal;">String</span> strFilePath)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (!<span style="color:teal;">File</span>.Exists(strFilePath)) <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:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">string</span> strExcelConn = <span style="color:maroon;">&#8220;Provider=Microsoft.ACE.OLEDB.12.0;&#8221;</span> +</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:maroon;">&#8220;Data Source=&#8221;</span> + strFilePath + <span style="color:maroon;">&#8220;;Excel 12.0;HDR=YES;&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:teal;">OleDbConnection</span> connExcel = <span style="color:blue;">new</span> <span style="color:teal;">OleDbConnection</span>(strExcelConn);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:teal;">OleDbCommand</span> cmdExcel = <span style="color:blue;">new</span> <span style="color:teal;">OleDbCommand</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span>       </span>cmdExcel.Connection = connExcel;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">//Check if the Sheet Exists</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">DataTable</span> dtExcelSchema;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>dtExcelSchema = </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.GetOleDbSchemaTable(<span style="color:teal;">OleDbSchemaGuid</span>.Tables, <span style="color:blue;">null</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">DataRow</span>[] dr = </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0 0 0 .5in;"><span style="font-size:10pt;font-family:&quot;"><span>  </span>dtExcelSchema.Select(<span style="color:maroon;">&#8220;TABLE_NAME = &#8216;tblData&#8217;&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">//if not Create the Sheet</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">if</span> (dr == <span style="color:blue;">null</span> || dr.Length == 0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>cmdExcel.CommandText = <span style="color:maroon;">&#8220;CREATE TABLE [tblData]&#8220;</span> + </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:maroon;">&#8221; (ID varchar(10), Name varchar(50));&#8221;</span>; ;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>connExcel.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>cmdExcel.ExecuteNonQuery();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">//Add New Row to Excel File </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>cmdExcel.CommandText = <span style="color:maroon;">&#8220;INSERT INTO [tblData]&#8220;</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>+ <span style="color:maroon;">&#8220;(ID, Name) values (&#8217;1&#8242;, &#8216;MAK&#8217;)&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Open(); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>cmdExcel.ExecuteNonQuery();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">catch</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">finally</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>cmdExcel.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>connExcel.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">}</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">To call the function on Button click.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">protected</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:green;">//Excel 97-2003</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>AddExcelRow(<span style="color:maroon;">&#8220;C:\\Book1.xls&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:green;">//Excel 2007</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>AddExcelRow2007(<span style="color:maroon;">&#8220;C:\\Book1.xlsx&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Please post your comments.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=42&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/12/export-data-to-excel-adonet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Check Whether UserName Already Exists</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/11/check-whether-username-already-exists/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/11/check-whether-username-already-exists/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 10:26:59 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Check]]></category>
		<category><![CDATA[serverside]]></category>
		<category><![CDATA[UserName]]></category>
		<category><![CDATA[XMLHttp]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=38</guid>
		<description><![CDATA[Many times I have seen people asking “How to identify whether username Exists” When it is typed Hence I decided to explain it here I will start with a TextBox for User Name and a Label which will display the message.   &#60;asp:TextBox ID=&#8221;txtUserName&#8221; runat=&#8221;server&#8221; onchange = &#8220;CheckUser(&#8216;XMLHTTP.aspx?UserName=&#8217; + this.value)&#8221;&#62; &#60;/asp:TextBox&#62;   &#60;asp:Label ID=&#8221;lblMsg&#8221; Text [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=38&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Many times I have seen people asking “How to identify whether username Exists” When it is typed</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Hence I decided to explain it here</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">I will start with a TextBox for User Name and a Label which will display the message.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;</span><span style="font-size:10pt;color:maroon;font-family:&quot;">asp</span><span style="font-size:10pt;color:blue;font-family:&quot;">:</span><span style="font-size:10pt;color:maroon;font-family:&quot;">TextBox</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;txtUserName&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:red;font-family:&quot;">onchange</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">=</span> <span style="color:blue;">&#8220;CheckUser(&#8216;XMLHTTP.aspx?UserName=&#8217; + this.value)&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;/</span><span style="font-size:10pt;color:maroon;font-family:&quot;">asp</span><span style="font-size:10pt;color:blue;font-family:&quot;">:</span><span style="font-size:10pt;color:maroon;font-family:&quot;">TextBox</span><span style="font-size:10pt;color:blue;font-family:&quot;">&gt;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;</span><span style="font-size:10pt;color:maroon;font-family:&quot;">asp</span><span style="font-size:10pt;color:blue;font-family:&quot;">:</span><span style="font-size:10pt;color:maroon;font-family:&quot;">Label</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMsg&#8221;</span> <span style="color:red;">Text</span> <span style="color:blue;">=</span> <span style="color:blue;">&#8220;UserExists&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">style</span> <span style="color:blue;">=&#8221; visibility:hidden &#8220;&gt;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;/</span><span style="font-size:10pt;color:maroon;font-family:&quot;">asp</span><span style="font-size:10pt;color:blue;font-family:&quot;">:</span><span style="font-size:10pt;color:maroon;font-family:&quot;">Label</span><span style="font-size:10pt;color:blue;font-family:&quot;">&gt;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">On the OnChange Event of the TextBox the CheckUser JavaScript dfunction will be called which is explained below.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">The label by default is invisible.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">Now I will be using JavaScript to make a AJAX Call to the Server and Check whether the User Name exists.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><strong><span style="font-size:10pt;font-family:&quot;">JavaScript Part</span></strong></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">To do that you will need to create XML Http Request.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;</span><span style="font-size:10pt;color:maroon;font-family:&quot;">script</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:red;">type</span> <span style="color:blue;">=</span> <span style="color:blue;">&#8220;text/javascript&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">var</span><span style="font-size:10pt;font-family:&quot;"> xmlhttp;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">function</span><span style="font-size:10pt;font-family:&quot;"> CheckUser(url) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>xmlhttp=<span style="color:blue;">null</span>; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (window.XMLHttpRequest) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">// code for all new browsers</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>xmlhttp=<span style="color:blue;">new</span> XMLHttpRequest(); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">else</span> <span style="color:blue;">if</span> (window.ActiveXObject) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">// code for IE5 and IE6xmlhttp=</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">new</span> ActiveXObject(<span style="color:maroon;">&#8220;Microsoft.XMLHTTP&#8221;</span>); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (xmlhttp!=<span style="color:blue;">null</span>) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>xmlhttp.onreadystatechange=state_Change;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>xmlhttp.open(<span style="color:maroon;">&#8220;GET&#8221;</span>,url,<span style="color:blue;">true</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>xmlhttp.send(<span style="color:blue;">null</span>); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>alert(<span style="color:maroon;">&#8220;Your browser does not support XMLHTTP.&#8221;</span>); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">The Above function creates a XML Http Request and sends it asynchronously to the Server.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">And when the Reponse is Received </span><span style="font-size:10pt;font-family:&quot;">the following function will be called.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">function</span><span style="font-size:10pt;font-family:&quot;"> state_Change() </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">if</span><span style="font-size:10pt;font-family:&quot;"> (xmlhttp.readyState==4) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{<span style="color:green;">// 4 = &#8220;loaded&#8221;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (xmlhttp.status==200) </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{<span style="color:green;">// 200 = OK<span>                </span></span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">// &#8230;our code here&#8230;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span><span style="color:blue;">var</span> lblMesg = document.getElementById(<span style="color:maroon;">&#8220;&lt;%=lblMsg.ClientID%&gt;&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span><span style="color:blue;">if</span>(xmlhttp.responseText==<span style="color:maroon;">&#8220;true&#8221;</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>lblMesg.style.visibility = <span style="color:maroon;">&#8220;visible&#8221;</span>;<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>      </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>lblMesg.style.visibility = <span style="color:maroon;">&#8220;hidden&#8221;</span>; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>      </span>alert(<span style="color:maroon;">&#8220;Problem retrieving XML data&#8221;</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}<span style="color:blue;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">&lt;/</span><span style="font-size:10pt;color:maroon;font-family:&quot;">script</span><span style="font-size:10pt;color:blue;font-family:&quot;">&gt;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><strong><span style="font-size:10pt;font-family:&quot;">CodeBehind Server Side (<span style="color:teal;">XMLHttpCSharp.aspx</span>)</span></strong></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><strong><span style="font-size:10pt;font-family:&quot;"> </span></strong></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">protected</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">void</span> Page_Load(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span><span style="color:blue;">if</span> (Request.QueryString[<span style="color:maroon;">"UserName"</span>] != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">String</span> strUserName = Request.QueryString[<span style="color:maroon;">"UserName"</span>]; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">//Check userName Here</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">String</span> strReturnStatus<span>   </span>= <span style="color:maroon;">&#8220;false&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">if</span> (CheckUsername(Request.QueryString[<span style="color:maroon;">"UserName"</span>]) = <span style="color:blue;">true</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>strReturnStatus = <span style="color:maroon;">&#8220;true&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>Response.Clear();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>Response.Write(strReturnStatus);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>Response.End();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">On PageLoad As you can see I am Accepting the UserName in the QueryString and then checking whether username exists using <strong>CheckUsername </strong>function. If It Exists I return true else false.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">Depending on the Response Received the state_change function Shows or Hides the label.</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=38&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/11/check-whether-username-already-exists/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Select Stored Procedures ADO.Net</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/10/using-select-stored-procedures-adonet/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/10/using-select-stored-procedures-adonet/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 18:36:41 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Stored Procedures]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=32</guid>
		<description><![CDATA[Here I will discuss how to get data using SQL Stored Procedure in ADO.Net Here’s the Function   First import the following Namespaces   using System.Data; using System.Data.SqlClient;   Now define your Connection string in the Web.Config &#60;connectionStrings&#62; &#60;add name=“conString“  connectionString=“DataSource=.\SQLEXPRESS;Database=Northwind; Integrated Security=true“/&#62; &#60;/connectionStrings&#62;     Here’s the function to call the Select Stored Procedure [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=32&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Here I will discuss how to get data using SQL Stored Procedure in ADO.Net</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Here’s the Function </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">First import the following Namespaces</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">using</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> System.Data;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">using</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> System.Data.SqlClient;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Now define your Connection string in the Web.Config</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">&lt;</span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">connectionStrings</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">&gt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">&lt;</span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">add</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:red;font-family:&quot;" lang="EN">name</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">=</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">“</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">conString</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">“</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:red;font-family:&quot;" lang="EN">connectionString</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">=</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">“</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">DataSource=.\SQLEXPRESS;Database=Northwind;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">Integrated Security=true</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">“</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">/&gt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">&lt;/</span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">connectionStrings</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">&gt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Here’s the function to call the Select Stored Procedure</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">public</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> GetData(</span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlCommand</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> cmd)</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">{</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt = </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">new</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">   </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">String</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> strConnString  </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">   =System.Configuration.</span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">ConfigurationManager</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">.ConnectionStrings[</span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">"conString"</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">].ConnectionString;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlConnection</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> con = </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">new</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlConnection</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">(strConnString);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    cmd.Connection = con;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlDataAdapter</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> sda = </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">new</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlDataAdapter</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    cmd.CommandType = </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">CommandType</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">.StoredProcedure;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">try</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    {</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        con.Open();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        sda.SelectCommand = cmd;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        sda.Fill(dt);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    }</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">catch</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    {</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">return</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    }</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">finally</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    {</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        con.Close();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        cmd.Dispose();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">        sda.Dispose();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    }</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">return</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">}</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">If Stored Procedure does not accept any input parameters. Call the above function in the following way.</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">protected</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">void</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> Button1_Click(</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">object</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> sender, </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">EventArgs</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> e)</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">{</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">String</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> strStoreProcName = </span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">“sp_GetCustomersByID”</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlCommand</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> cmd = </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">new</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlCommand</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">(strStoreProcName);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">}</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">If Stored Procedure accepts input parameters, you can add in the following way. </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">protected</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">void</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> Button1_Click(</span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">object</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> sender, </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">EventArgs</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> e)</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">{</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">String</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> strStoreProcName = </span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">“sp_GetCustomersByID”</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlCommand</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> cmd = </span><span style="font-size:10pt;color:blue;font-family:&quot;" lang="EN">new</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">SqlCommand</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">(strStoreProcName);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"><span>    </span></span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">cmd.Parameters.AddWithValue(</span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">“@CustomerID”</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">, </span><span style="font-size:10pt;color:maroon;font-family:&quot;" lang="EN">“ALFKI”</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">); </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">    </span><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">}</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">You can bind the Returned DataTable to any Data Bound Controls like GridView, DataGrid, DropDownList and others in the following way</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:teal;font-family:&quot;" lang="EN">DataTable</span><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">GridView1.DataSource = dt;</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">GridView1.DataBind();</span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN"> </span></p>
<p class="MsoNormal" style="background:white;line-height:normal;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;" lang="EN">Please do comment If you want something to be added in the Blog which you want to learn.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=32&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/10/using-select-stored-procedures-adonet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing XML Files Using ADO.Net</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/10/accessing-xml-files-using-adonet/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/10/accessing-xml-files-using-adonet/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 12:49:33 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DataSet]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Read XML]]></category>
		<category><![CDATA[Write XML]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=29</guid>
		<description><![CDATA[Here I will discuss regarding Accessing XML files using ADO.Net Consider an XML File &#60;CustomerDataSet&#62;             &#60;CustomerTable&#62;                         &#60;Name&#62;John&#60;/Name&#62;                         &#60;Age&#62;34&#60;/Age&#62;             &#60;/CustomerTable&#62;             &#60;CustomerTable&#62;                         &#60;Name&#62;Smith&#60;/Name&#62;                         &#60;Age&#62;26&#60;/Age&#62;             &#60;/CustomerTable&#62; &#60;/CustomerDataSet&#62;   Here CustomerDataSet contains one Table called CustomerTable which has two Columns Name Age And Currently the Table has 2 records.   Now [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=29&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Here I will discuss regarding Accessing XML files using ADO.Net</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Consider an XML File</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">&lt;CustomerDataSet&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>            </span>&lt;CustomerTable&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>                        </span>&lt;Name&gt;John&lt;/Name&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>                        </span>&lt;Age&gt;34&lt;/Age&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>            </span>&lt;/CustomerTable&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>            </span>&lt;CustomerTable&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>                        </span>&lt;Name&gt;Smith&lt;/Name&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>                        </span>&lt;Age&gt;26&lt;/Age&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"><span>            </span>&lt;/CustomerTable&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">&lt;/CustomerDataSet&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Here CustomerDataSet contains one Table called CustomerTable which has two Columns</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Name</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Age</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">And Currently the Table has 2 records.</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Now to Read the XML File we will use DataSet ReadXML Property.</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Syntax</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataSet</span><span style="font-size:10pt;font-family:&quot;"> ds = <span style="color:blue;">new</span> <span style="color:teal;">DataSet</span>();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">ds.ReadXml(<span style="color:maroon;">&lt;XML FilePath&gt;</span>) ;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Example</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Consider that the file Customers.XML is stored in C:\</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataSet</span><span style="font-size:10pt;font-family:&quot;"> ds = <span style="color:blue;">new</span> <span style="color:teal;">DataSet</span>();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">ds.ReadXml(<span style="color:maroon;">&#8220;C:\\Customers.XML&#8221;</span>) ;</span><span style="font-family:&quot;"></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">After this is done you can bind your DataSet to any data bound controls like </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">GridView, DataGrid, Repeater, DropDownList and many others using their</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">DataSource Property.</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Example</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataSet</span><span style="font-size:10pt;font-family:&quot;"> ds = <span style="color:blue;">new</span> <span style="color:teal;">DataSet</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">ds.ReadXml(<span style="color:maroon;">&#8220;C:\\Customers.XML&#8221;</span>) ;</span><span style="font-family:&quot;"></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">GridView1.DataSource = ds;</span><span style="font-family:&quot;"></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">GridView1.DataBind();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">To Add New Rows To your XML File you can use the DataSet WriteXML Property</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Syntax</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">Syntax</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataSet</span><span style="font-size:10pt;font-family:&quot;"> ds = <span style="color:blue;">new</span> <span style="color:teal;">DataSet</span>();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">ds.WriteXML(<span style="color:maroon;">&lt;XML FilePath&gt;</span>) ;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">Example</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].Rows.Add();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].Rows[ds.Tables[0].Rows.Count &#8211; 1][<span style="color:maroon;">"Name"</span>] = <span style="color:maroon;">&#8220;MAK&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].Rows[ds.Tables[0].Rows.Count &#8211; 1][<span style="color:maroon;">"Age"</span>] = <span style="color:maroon;">&#8220;23&#8243;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].AcceptChanges();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;line-height:115%;font-family:&quot;">ds.WriteXml(<span style="color:maroon;">&#8220;C:\\Customers.XML&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&quot;"><span style="font-size:small;">To Search for An Existing Record and Update the Record, you will have to Query the DataSet in the following way.</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataRow</span><span style="font-size:10pt;font-family:&quot;">[] dr = ds.Tables[0].Select(<span style="color:maroon;">&#8220;Name = &#8216;Smith&#8217;&#8221;</span>); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">if</span><span style="font-size:10pt;font-family:&quot;"> (dr!=<span style="color:blue;">null</span> &amp;&amp; dr.Length &gt; 0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>dr[0][<span style="color:maroon;">"Age"</span>] = <span style="color:maroon;">&#8220;25&#8243;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].AcceptChanges();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">To Delete a Particular Record.<span>  </span></span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;"> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:teal;font-family:&quot;">DataRow</span><span style="font-size:10pt;font-family:&quot;">[] dr = ds.Tables[0].Select(<span style="color:maroon;">&#8220;Name = &#8216;MAK&#8217;&#8221;</span>); </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">if</span><span style="font-size:10pt;font-family:&quot;"> (dr!=<span style="color:blue;">null</span> &amp;&amp; dr.Length &gt; 0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>ds.Tables[0].Rows.Remove(dr[0]);<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">ds.Tables[0].AcceptChanges();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-family:&quot;"><span style="font-size:small;">Thus all the Database Operations such as Add, Update Delete and Search can be performed on XML Files also using DataSet</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=29&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/10/accessing-xml-files-using-adonet/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Disable Browser Back Button</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/10/disable-browser-back-button/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/10/disable-browser-back-button/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 09:19:20 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Back]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Button]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=27</guid>
		<description><![CDATA[Here I will discuss how to prevent user’s from going to previous page using Browser Back button   Consider the scenario User comes to Page A does some work and is Redirected to Page B. Page A &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;à Page B   Now if user clicks Browser Back button he can go back to Page A. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=27&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Here I will discuss how to prevent user’s from going to previous page using Browser Back button</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Consider the scenario</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">User comes to Page A does some work and is Redirected to Page B.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;"><span style="font-family:Calibri;">Page A &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span><span style="font-family:Wingdings;"><span>à</span></span><span style="font-family:Calibri;"> Page B</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Now if user clicks Browser Back button he can go back to Page A.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;"><span style="font-family:Calibri;">Page B&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span><span style="font-family:Wingdings;"><span>à</span></span><span style="font-family:Calibri;"> Page A</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">To prevent this you can do this trick by adding this script in the body of Page A</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:10pt;color:blue;line-height:115%;font-family:&quot;">&lt;</span><span style="font-size:10pt;color:maroon;line-height:115%;font-family:&quot;">body</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"> <span style="color:red;">onload</span><span style="color:blue;">=&#8221;if(history.length&gt;0)history.go(+1);&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">When you add this in the index of Page A, Page B is cached So even if user clicks browser back button he cannot go back.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">But even though it works well in IE Firefox does not allow this script to run in events where user interaction is not there. Hence the above technique works only for IE.</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=27&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/10/disable-browser-back-button/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Execute SQL Select Query using ADO.Net</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/10/execute-sql-select-query-using-adonet/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/10/execute-sql-select-query-using-adonet/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 06:42:39 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=22</guid>
		<description><![CDATA[Here I will discuss how to get data using SQL Select Query in ADO.Net Here’s the Function   First import the following Namespaces   using System.Data; using System.Data.SqlClient;   Now define your Connection string in the Web.Config &#60;connectionStrings&#62; &#60;add name=&#8220;conString&#8220;  connectionString=&#8220;DataSource=.\SQLEXPRESS;Database=Northwind;Integrated Security=true&#8220;/&#62; &#60;/connectionStrings&#62;     Here’s the function public DataTable GetData(SqlCommand cmd) {     DataTable [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=22&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">Here I will discuss how to get data using SQL Select Query in ADO.Net</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">Here’s the Function </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">First import the following Namespaces</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">using</span><span style="font-size:9pt;font-family:&quot;"> System.Data;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:&quot;">using</span><span style="font-size:9pt;line-height:115%;font-family:&quot;"> System.Data.SqlClient;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">Now define your Connection string in the Web.Config</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">&lt;</span><span style="font-size:9pt;color:maroon;font-family:&quot;">connectionStrings</span><span style="font-size:9pt;color:blue;font-family:&quot;">&gt;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">&lt;</span><span style="font-size:9pt;color:maroon;font-family:&quot;">add</span><span style="font-size:9pt;color:blue;font-family:&quot;"> </span><span style="font-size:9pt;color:red;font-family:&quot;">name</span><span style="font-size:9pt;color:blue;font-family:&quot;">=</span><span style="font-size:9pt;font-family:&quot;">&#8220;<span style="color:blue;">conString</span>&#8220;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;"><span> </span></span><span style="font-size:9pt;color:red;font-family:&quot;">connectionString</span><span style="font-size:9pt;color:blue;font-family:&quot;">=</span><span style="font-size:9pt;font-family:&quot;">&#8220;<span style="color:blue;">DataSource=.\SQLEXPRESS;Database=Northwind;Integrated Security=true</span>&#8220;<span style="color:blue;">/&gt;</span></span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:&quot;">&lt;/</span><span style="font-size:9pt;color:maroon;line-height:115%;font-family:&quot;">connectionStrings</span><span style="font-size:9pt;color:blue;line-height:115%;font-family:&quot;">&gt;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:blue;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">Here’s the function </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">public</span><span style="font-size:9pt;font-family:&quot;"> <span style="color:teal;">DataTable</span> GetData(<span style="color:teal;">SqlCommand</span> cmd)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">DataTable</span> dt = <span style="color:blue;">new</span> <span style="color:teal;">DataTable</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>  </span><span> </span><span style="color:teal;">String</span> strConnString <span> </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>   </span>=System.Configuration.<span style="color:teal;">ConfigurationManager</span>.ConnectionStrings[<span style="color:maroon;">"conString"</span>].ConnectionString;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">SqlConnection</span> con = <span style="color:blue;">new</span> <span style="color:teal;">SqlConnection</span>(strConnString);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>cmd.Connection = con;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">SqlDataAdapter</span> sda = <span style="color:blue;">new</span> <span style="color:teal;">SqlDataAdapter</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>cmd.CommandType = <span style="color:teal;">CommandType</span>.Text;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>con.Open();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>sda.SelectCommand = cmd;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>sda.Fill(dt);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:blue;">catch</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span><span style="color:blue;">return</span> dt;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:blue;">finally</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>con.Close();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>cmd.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>        </span>sda.Dispose();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:blue;">return</span> dt;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">To call the above function without any parameters</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">protected</span><span style="font-size:9pt;font-family:&quot;"> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">String</span> strQuery = <span style="color:maroon;">&#8220;SELECT * FROM Customers&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">SqlCommand</span> cmd = <span style="color:blue;">new</span> <span style="color:teal;">SqlCommand</span>(strQuery);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">DataTable</span> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">And Now to call the above query using parameters. That I need only those records which have CustomerID as ALFKI. Here I am using Parameterized Queries So that SQL Injections can be avoided.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">So the function will be called this way.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;color:blue;font-family:&quot;">protected</span><span style="font-size:9pt;font-family:&quot;"> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">String</span> strQuery = <span style="color:maroon;">&#8220;SELECT * FROM Customers WHERE CustomerID=@CustomerID&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">SqlCommand</span> cmd = <span style="color:blue;">new</span> <span style="color:teal;">SqlCommand</span>(strQuery);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span>cmd.Parameters.AddWithValue(<span style="color:maroon;">&#8220;@CustomerID&#8221;</span>, <span style="color:maroon;">&#8220;ALFKI&#8221;</span>);<span>  </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:9pt;font-family:&quot;"><span>    </span><span style="color:teal;">DataTable</span> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">}</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">You can bind the Returned DataTable to any DataBound Controls like Gridview, DataGrid, DropDownList and others in the following way</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;color:teal;line-height:115%;font-family:&quot;">DataTable</span><span style="font-size:9pt;line-height:115%;font-family:&quot;"> dt = GetData(cmd);</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">GridView1.DataSource = dt;</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">GridView1.DataBind();</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;">Please do comment If you want something to be added in the Blog which you want to learn.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:9pt;line-height:115%;font-family:&quot;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=22&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/10/execute-sql-select-query-using-adonet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
		<item>
		<title>Send Email Using C#</title>
		<link>http://mudassarkhan.wordpress.com/2009/01/09/send-email-using-c/</link>
		<comments>http://mudassarkhan.wordpress.com/2009/01/09/send-email-using-c/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:31:55 +0000</pubDate>
		<dc:creator>mudassarkhan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[threading]]></category>

		<guid isPermaLink="false">http://mudassarkhan.wordpress.com/?p=15</guid>
		<description><![CDATA[Here I have discussed How to send Emails using C#. See the function below public Boolean sendemail(String strTo, string strFrom, string strSubject, string strBody,string strAttachmentPath, bool IsBodyHTML)     {         Array arrToArray;         char[] splitter = { &#8216;;&#8217; };         arrToArray = strTo.Split(splitter);           MailMessage mm = new MailMessage();             mm.From = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=15&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="line-height:14.25pt;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;">Here I have discussed How to send Emails using C#. </span></p>
<p class="MsoNormal" style="line-height:14.25pt;margin:0 0 10pt;"><span style="font-size:10pt;color:black;font-family:&quot;">See the function below</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">public</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:teal;">Boolean</span> sendemail(<span style="color:teal;">String</span> strTo, <span style="color:blue;">string</span> strFrom, <span style="color:blue;">string</span> strSubject, <span style="color:blue;">string</span> strBody,<span style="color:blue;">string</span> strAttachmentPath, <span style="color:blue;">bool</span> IsBodyHTML)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">Array</span> arrToArray;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">char</span>[] splitter = { <span style="color:maroon;">&#8216;;&#8217;</span> };</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>arrToArray = strTo.Split(splitter);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">MailMessage</span> mm = <span style="color:blue;">new</span> <span style="color:teal;">MailMessage</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.From = <span style="color:blue;">new</span> <span style="color:teal;">MailAddress</span>(strFrom);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.Subject = strSubject;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.Body = strBody;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>mm.IsBodyHtml = IsBodyHTML;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">foreach</span> (<span style="color:blue;">string</span> s <span style="color:blue;">in</span> arrToArray)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm.To.Add(<span style="color:blue;">new</span> <span style="color:teal;">MailAddress</span>(s));</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">if</span> (strAttachmentPath != <span style="color:maroon;">&#8220;&#8221;</span>)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">//Add Attachment</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:teal;">Attachment</span> attachFile = <span style="color:blue;">new</span> <span style="color:teal;">Attachment</span>(strAttachmentPath);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm.Attachments.Add(attachFile);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:teal;">SmtpClient</span> smtp = <span style="color:blue;">new</span> <span style="color:teal;">SmtpClient</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">try</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span><span style="color:green;">//(4) Send the MailMessage (will use the Web.config settings)</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Host = <span style="color:maroon;">&#8220;YourSmtpServer&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.EnableSsl = <span style="color:maroon;">&#8220;true/false&#8221;</span>; <span style="color:green;">//Depending on server SSL Settings</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>System.Net.<span style="color:teal;">NetworkCredential</span> NetworkCred = <span style="color:blue;">new</span> System.Net.<span style="color:teal;">NetworkCredential</span>();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>NetworkCred.UserName = <span style="color:maroon;">&#8220;Your Email&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>NetworkCred.Password = <span style="color:maroon;">&#8220;Your Password&#8221;</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.UseDefaultCredentials = <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Credentials = NetworkCred;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Port = 000;<span style="color:green;">//Specify your port No;</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp.Send(mm);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:blue;">catch</span> (<span style="color:teal;">Exception</span> ex)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>mm = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>            </span>smtp = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;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:10pt;font-family:&quot;"><span>        </span>}<span>    </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">}</span><span style="font-size:9pt;color:black;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:13.5pt;margin:0;"><span style="font-size:9pt;color:black;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:13.5pt;margin:0;"><span style="font-size:9pt;color:black;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:13.5pt;margin:0;"><span style="font-size:9pt;color:black;font-family:&quot;"> To call this function </span></p>
<p class="MsoNormal" style="line-height:13.5pt;margin:0;"><span style="font-size:9pt;color:black;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">protected</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="text-indent:.5in;line-height:normal;margin:0;"><span style="font-size:10pt;color:green;font-family:&quot;">//Without Attachment</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>sendemail(<span style="color:maroon;">&#8220;recepient@abc.com&#8221;</span>, <span style="color:maroon;">&#8220;sender@xyz.com&#8221;</span>, <span style="color:maroon;">&#8220;Subject&#8221;</span>, <span style="color:maroon;">&#8220;Body&#8221;</span>, <span style="color:maroon;">&#8220;&#8221;</span>, <span style="color:blue;">true</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span><span style="color:green;">//With Attachment</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>        </span>sendemail(<span style="color:maroon;">&#8220;recepient@abc.com&#8221;</span>, <span style="color:maroon;">&#8220;sender@xyz.com&#8221;</span>, <span style="color:maroon;">&#8220;Subject&#8221;</span>, <span style="color:maroon;">&#8220;Body&#8221;</span>, <span style="color:maroon;">&#8220;c:\\mypdf.pdf&#8221;</span>, <span style="color:blue;">true</span>);}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">You can also use threading so that your page does not wait for the email to get send and the users get a quick response and mail is send in background</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">To do that</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:&quot;">protected</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">void</span> Button1_Click(<span style="color:blue;">object</span> sender, <span style="color:teal;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>  </span>System.Threading.<span style="color:teal;">Thread</span> threadSendMails;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span>  </span>threadSendMails = <span style="color:blue;">new</span> System.Threading.<span style="color:teal;">Thread</span>(<span style="color:blue;">delegate</span>() { <span>   </span>sendemail(<span style="color:maroon;">&#8220;recepient@abc.com&#8221;</span>, <span style="color:maroon;">&#8220;sender@xyz.com&#8221;</span>, <span style="color:maroon;">&#8220;Subject&#8221;</span>, <span style="color:maroon;">&#8220;Body&#8221;</span>, “”, <span style="color:blue;">true</span>); });</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span> </span>threadSendMails.IsBackground = <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span> </span>threadSendMails.Start();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"><span> </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">Also these are the settings for sending email using Gmail</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">Host &#8211; smtp.gmail.com</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">SSL – true</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">PortNo 465 or just comment portNo</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">UserName – Gmail Email</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;">Password Gmail Password</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mudassarkhan.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mudassarkhan.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mudassarkhan.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mudassarkhan.wordpress.com&amp;blog=6112370&amp;post=15&amp;subd=mudassarkhan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mudassarkhan.wordpress.com/2009/01/09/send-email-using-c/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/66ab4fe4ade025d4e0e4714c8cfd63b4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mudassarkhan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
