<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4981218661818789875</atom:id><lastBuildDate>Wed, 06 Nov 2024 02:48:06 +0000</lastBuildDate><category>.NET</category><category>ms access</category><category>sql server</category><category>VB</category><category>html</category><category>javascript</category><category>AJAX</category><category>excel</category><category>PHP</category><category>my sql</category><category>oracle</category><category>source safe</category><category>CSS</category><category>LINQ</category><category>java</category><category>web service</category><title>July Code Blog</title><description>Web Development and Programming Blog</description><link>http://july-code.blogspot.com/</link><managingEditor>noreply@blogger.com (xiaoyu)</managingEditor><generator>Blogger</generator><openSearch:totalResults>100</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-9062073964600382012</guid><pubDate>Fri, 21 Oct 2011 03:18:00 +0000</pubDate><atom:updated>2011-10-21T11:18:43.602+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>There was a failure while initializing the Microsoft Visual SourceSafe source control provider</title><description>&lt;div style=&quot;text-align: left;&quot;&gt;I kept getting this error when I was trying to open my project.&amp;nbsp;&lt;/div&gt;&lt;blockquote style=&quot;text-align: left;&quot;&gt;There was a failure while initializing the Microsoft Visual SourceSafe source control provider. You cannot use this provider to perform source control operations.&lt;/blockquote&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Here is the solution:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;1. Open VS2005, go to menu Tools -&amp;gt; Options, then click &quot;Source Control&quot;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;2. Choose &quot;None&quot; for the drop-down list under &quot;Current souce control plug-in&quot;, rather then &quot;Microsoft Visual Source Safe&quot;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Reference:&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en-US/vssourcecontrol/thread/255dfa57-87ab-4db5-ab9b-b79a0c6dc1b7&quot;&gt;http://social.msdn.microsoft.com/Forums/en-US/vssourcecontrol/thread/255dfa57-87ab-4db5-ab9b-b79a0c6dc1b7&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2011/10/there-was-failure-while-initializing.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-2065335607413391535</guid><pubDate>Mon, 25 Jul 2011 07:09:00 +0000</pubDate><atom:updated>2011-07-25T15:09:09.454+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">java</category><title>java.util.ConcurrentModificationException with ArrayList</title><description>You will receive java.util.ConcurrentModicationException error, if you are modifying a list while iterating it. For example, the following code will throw you the exception:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;for&lt;/span&gt; (Object obj : list) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;if (obj.getCode().equals(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;something&quot;&lt;/span&gt;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.remove(obj);&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To avoid this exception, the trick is to delete/add an item through the iterator, but not the collection. Here is the example:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;Iterator it = list.iterator();&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt; while&lt;/span&gt; (it.hasNext()) {  &lt;br /&gt;
&amp;nbsp;&amp;nbsp;Object obj = (Object)it.next();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;if (obj.getCode().equals(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;something&quot;&lt;/span&gt;)) {       &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp; &amp;nbsp; it.remove();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
}&lt;/code&gt; &lt;br /&gt;
&lt;br /&gt;
Hope this helps.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2011/07/javautilconcurrentmodificationexception.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-7343862118958400541</guid><pubDate>Fri, 06 May 2011 09:05:00 +0000</pubDate><atom:updated>2011-05-06T17:05:10.827+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>The referenced assembly could not be resolved because it has a dependency on System.Data.OracleClient</title><description>Received the following build error:&lt;br /&gt;
&lt;code&gt;The referenced assembly &quot;xxx&quot; could not be resolved because it has a dependency on &quot;System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot; which is not in the currently targeted framework &quot;.NETFramework,Version=v4.0,Profile=Client&quot;. Please remove references to assemblies not in the targeted framework or consider re-targeting your project.&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This build error is caused by the project is targeting .NET Framework 4.0 Client Profile and references to an assembly, which has indirect reference on System.Data.OracleClient.dll that is not included in the .NET Framework 4 Client Profile.&lt;br /&gt;
&lt;br /&gt;
To fix such errors, you can either remove the incorrect assembly reference from the project, or set the project to target to full .NET Framework version 4 instead of .NET Framework 4 Client Profile.&lt;br /&gt;
&lt;br /&gt;
To change the target setting, go to “Project -&gt; Project&#39;s Properties -&gt; Application Tab”, and then change to appropriate Target Framework options.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2011/05/referenced-assembly-could-not-be.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-7744837369328783863</guid><pubDate>Tue, 12 Apr 2011 03:08:00 +0000</pubDate><atom:updated>2011-04-12T11:13:28.091+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSS</category><category domain="http://www.blogger.com/atom/ns#">html</category><title>Resize image without distorting it</title><description>Has anyone come across a problem where image is being distorted on a webpage? &lt;br /&gt;
&lt;br /&gt;
Here is the simple CSS solution to display images without distorted. &lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;head&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;style&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;text/css&quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000; font-family: monospace;&quot;&gt;.imgresize&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;width:&lt;/span&gt; 100px;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;height:&lt;/span&gt; 150px;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000; font-family: monospace;&quot;&gt;.imgresize img&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;width:&lt;/span&gt; 100px; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// to fix images by width, or&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: monospace;&quot;&gt;// height: 150px;     // to fix images by height&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;style&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;head&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;runa&lt;/span&gt;t&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;imgdiv&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;imgresize&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;images/image01.gif&quot;&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;form&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #660000;&quot;&gt;html&lt;/span&gt;&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Note: You need to remove the height and width attribute value from img tag itself.&lt;br /&gt;
&lt;br /&gt;
Reference link &lt;a href=&quot;http://forums.asp.net/p/1514562/3619288.aspx&quot; target=&quot;_blank&quot;&gt;http://forums.asp.net/p/1514562/3619288.aspx&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2011/04/resize-image-without-distorting-it.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-5382788324653146754</guid><pubDate>Sun, 22 Aug 2010 04:12:00 +0000</pubDate><atom:updated>2011-07-25T15:09:39.561+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PHP</category><title>&quot;Strict standards : Non-static methods called statically&quot; Error after Joomla Installation</title><description>Recently I&#39;m merely setting up a test site on localhost to check out Joomla features. After the installation, there are tons of Strict standards errors appear on my screen when I browse to Joomla homepage. I tried to reinstall several times but it still gave me the same errors.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt21eYbCMwilDFhqlSi1top5uy9Wfh11_TJq1XE_7Dh1VUxLGAZjaWFPCzVPwqB_z1FOa_rQ4u6IxMi6tsZmCyIUrwZez3ovtth5dCDJj1KmWaf1JMgWOp7saPDvfy5VStx374TLTfmKZz/s1600/strick+standards+error.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;321&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt21eYbCMwilDFhqlSi1top5uy9Wfh11_TJq1XE_7Dh1VUxLGAZjaWFPCzVPwqB_z1FOa_rQ4u6IxMi6tsZmCyIUrwZez3ovtth5dCDJj1KmWaf1JMgWOp7saPDvfy5VStx374TLTfmKZz/s640/strick+standards+error.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Finally, I found something useful on &lt;a href=&quot;http://forum.joomla.org/viewtopic.php?f=429&amp;amp;t=271244&quot; target=_blank&gt;Joomla! Discussion Forums&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
To solve this issue, simply change the following configuration in your php.ini file.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;Change &lt;code&gt;error_reporting = E_ALL | E_STRICT&lt;/code&gt; to &lt;code&gt;error_reporting = E_ALL &amp;amp; ~E_STRICT&lt;/code&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;Change &lt;code&gt;display_errors = On&lt;/code&gt; to &lt;code&gt;display_errors = Off&lt;/code&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Remember to restart your Apache server after the changes. You should be able to view to Joomla! homepage now.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2010/08/strict-standards-non-static-methods.html</link><author>noreply@blogger.com (xiaoyu)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt21eYbCMwilDFhqlSi1top5uy9Wfh11_TJq1XE_7Dh1VUxLGAZjaWFPCzVPwqB_z1FOa_rQ4u6IxMi6tsZmCyIUrwZez3ovtth5dCDJj1KmWaf1JMgWOp7saPDvfy5VStx374TLTfmKZz/s72-c/strick+standards+error.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-1353875642810384895</guid><pubDate>Fri, 30 Jul 2010 01:45:00 +0000</pubDate><atom:updated>2010-07-30T10:04:33.099+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><title>Resize Textbox/Textarea based on content length</title><description>I was asked to implement resizing textbox based on content length in one of my projects, to avoid having to deal with scroll bars.&lt;br /&gt;&lt;br /&gt;And here is the code that works for me:&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;function&lt;/span&gt; textAreaResize(o) {&lt;br /&gt;   &amp;nbsp;&amp;nbsp;o.style.height = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&quot;1px&quot;&lt;/span&gt;;&lt;br /&gt;   &amp;nbsp;&amp;nbsp;o.style.height = (25+o.scrollHeight)+&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&quot;px&quot;&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;textarea&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;textArea1&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;onkeyup=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;textAreaResize(this)&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt; style=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;overflow:hidden&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;textarea&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;asp:textbox&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;txt1&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;runat=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;server&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;Width=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;500px&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;Height=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;25px&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt; TextMode=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;MultiLine&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;onkeyup=&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&quot;textAreaResize(this);&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;asp:textbox&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Anyway, I found out that this method is works for me only when I type my text in the box.&lt;br /&gt;&lt;br /&gt;It is not working when I having no focus on the textbox and call the &lt;code&gt;textAreaResize&lt;/code&gt; method to resize it. Position the cursor at the end of the text will resolve the issue.&lt;br /&gt;&lt;br /&gt;Try the following code to your page.&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;function&lt;/span&gt; textAreaResize(o) {&lt;br /&gt;   &amp;nbsp;&amp;nbsp;SetCursorToTextEnd(o.id); &lt;br /&gt;   &amp;nbsp;&amp;nbsp;o.style.height = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&quot;1px&quot;&lt;/span&gt;;&lt;br /&gt;   &amp;nbsp;&amp;nbsp;o.style.height = (25+o.scrollHeight)+&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&quot;px&quot;&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;function&lt;/span&gt; SetCursorToTextEnd(textControlID)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;var&lt;/span&gt; text = document.getElementById(textControlID);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;if&lt;/span&gt; (text != &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; text.value.length &amp;gt; 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;if&lt;/span&gt; (text.createTextRange) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;                var&lt;/span&gt; FieldRange = text.createTextRange();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;               FieldRange.moveStart(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;&#39;character&#39;&lt;/span&gt;, text.value.length);&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;             FieldRange.collapse();&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;             FieldRange.select();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Call the &lt;code&gt;textAreaResize&lt;/code&gt; method on your page load will do.&lt;br /&gt;&lt;br /&gt;Hope it works for you too. =)&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2010/07/resize-textboxtextarea-based-on-content.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-6958154758594925156</guid><pubDate>Wed, 02 Jun 2010 02:54:00 +0000</pubDate><atom:updated>2010-06-02T11:02:34.583+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sql server</category><title>Update Query with a JOIN Statement</title><description>I found something useful when I am trying to update columns in a master table (tbl1) from data in a temp table (tbl2). These updates can be done by making a query to update a table by doing &lt;span style=&quot;color:#666666;&quot;&gt;INNER JOIN&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Below is the example of a joined update query:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;UPDATE&lt;/span&gt; &lt;span style=&quot;color:#333333;&quot;&gt;tbl1&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET&lt;/span&gt; &lt;span style=&quot;color:#333333;&quot;&gt;field_name = B.field_name&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color:#333333;&quot;&gt;tbl1 A&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#666666;&quot;&gt;INNER JOIN&lt;/span&gt; &lt;span style=&quot;color:#333333;&quot;&gt;tbl2 B&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;ON&lt;/span&gt; &lt;span style=&quot;color:#333333;&quot;&gt;A.ID = B.ID&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2010/06/update-query-with-join-statement.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-2135550662900734670</guid><pubDate>Tue, 29 Dec 2009 07:59:00 +0000</pubDate><atom:updated>2009-12-29T16:03:16.377+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ms access</category><category domain="http://www.blogger.com/atom/ns#">my sql</category><category domain="http://www.blogger.com/atom/ns#">oracle</category><category domain="http://www.blogger.com/atom/ns#">sql server</category><title>Generate random rows with SQL</title><description>The secret to retrieve random rows from database is really simple. Here are some example SQL statements that do not require additional application logic.&lt;br /&gt;&lt;br /&gt;SQL Server:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT TOP&lt;/span&gt; 1 *&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; Users&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;ORDER BY NEWID&lt;/span&gt;()&lt;br /&gt;&lt;br /&gt;MySQL:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; Users&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;ORDER BY RAND()&lt;br /&gt;LIMIT&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC33CC;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;Oracle:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt;&lt;br /&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; Users&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;ORDER BY&lt;/span&gt; dbms_random.value )&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;WHERE&lt;/span&gt; rownum = 1&lt;br /&gt;&lt;br /&gt;PostgreSQL:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT&lt;/span&gt; * &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; Users&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;ORDER BY RANDOM()&lt;br /&gt;LIMIT&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#CC33CC;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Access:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;SELECT TOP&lt;/span&gt; 1 *&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;FROM&lt;/span&gt; Users&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;ORDER BY Rnd&lt;/span&gt;(UserID)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/12/generate-random-rows-with-sql.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-5757194491376340697</guid><pubDate>Fri, 09 Oct 2009 02:40:00 +0000</pubDate><atom:updated>2010-07-29T23:43:17.263+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>InvalidOperationException: Cross-thread operation not valid: Control ‘Form1’ accessed from a thread other than the thread it was created on.</title><description>When I first time met with this error, it was caused by an update of a windows form control from a separate thread.&lt;br /&gt;&lt;br /&gt;Here is the workaround.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;// delegation to cross the thread boundary&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;private delegate void&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;AddComboBoxItemDelegate&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;object&lt;/span&gt; item);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;private void&lt;/span&gt; AddComboBoxItem(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;object&lt;/span&gt; item)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;this&lt;/span&gt;.comboBox1.InvokeRequired) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#009900;&quot;&gt;// Invoke delegate so that the main UI thread is able to update the controls in the form&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;style=&quot;color:#000099;&quot;&gt;this&lt;/span&gt;.comboBox1.Invoke(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#339999;&quot;&gt;AddComboBoxItemDelegate&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;this&lt;/span&gt;.AddComboBoxItem), item);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;else&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;this&lt;/span&gt;.comboBox1.Items.Add(item);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps. Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/10/invalidoperationexception-cross-thread.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-20672218736326888</guid><pubDate>Wed, 16 Sep 2009 04:10:00 +0000</pubDate><atom:updated>2009-09-16T12:18:01.926+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sql server</category><title>Shrinking Transaction Log File in SQL SERVER</title><description>Sometimes it is necessary to shrink a transaction log in a database manually if the log file grows unexpectedly in order to save some disk space.&lt;br /&gt;&lt;br /&gt;Here are the steps use to truncate transaction log in a database:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;BACKUP&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF6666;&quot;&gt;LOG&lt;/span&gt; &amp;lt;databasename&amp;gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;TO DISK&lt;/span&gt; = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&#39;&amp;lt;backupfile&amp;gt;&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;DBCC&lt;/span&gt; SHRINKFILE (&amp;lt;filename&amp;gt;, &amp;lt;targetsize&amp;gt;) &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;WITH NO_INFOMSGS&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;e.g.:&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;BACKUP&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF6666;&quot;&gt;LOG&lt;/span&gt; NORTHWND &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;TO DISK&lt;/span&gt; = &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&#39;C:\NorthwindLog.bak&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;DBCC&lt;/span&gt; SHRINKFILE (Northwind_log, 100) &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;WITH NO_INFOMSGS&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To check your logical file name of your log file, you can run the query as below to get the logical file name something like &lt;code&gt;&#39;xxx_log&#39;&lt;/code&gt;:&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;sp_helpdb&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&#39;&amp;lt;databasename&amp;gt;&#39;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;More information:&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms189493.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms189493.aspx&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://support.microsoft.com/kb/907511&quot;&gt;http://support.microsoft.com/kb/907511&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/09/shrinking-transaction-log-file-in-sql.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-900007507730119834</guid><pubDate>Tue, 25 Aug 2009 07:29:00 +0000</pubDate><atom:updated>2009-08-25T15:39:34.690+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">LINQ</category><title>CS0234: The type or namespace name &#39;Linq&#39; does not exist in the namespace &#39;System.Data&#39; (are you missing an assembly reference?)</title><description>Add the line below into web.config:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#990000;&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;assembly&lt;/span&gt;=&quot;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089&lt;/span&gt;&quot;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Reference: http://forums.asp.net/t/1264863.aspx&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/08/cs0234-type-or-namespace-name-linq-does.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-578001357024629106</guid><pubDate>Thu, 11 Jun 2009 02:23:00 +0000</pubDate><atom:updated>2010-07-29T23:41:21.226+08:00</atom:updated><title>System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase</title><description>I came across with this error yesterday and just had to share it.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;CAUSE:&lt;/strong&gt; You have installed Internet Information Services (IIS) after the installation of .NET Framework 2.0&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RESOLUTION:&lt;/strong&gt; Repair your .NET Framework 2.0 by running the following command line to reset the IIS registry settings for aspnet user.&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;C:\WINDWOS\Microsoft.NET\Framework\v2.0.50727&gt;aspnet_regiis -i&lt;/em&gt;&lt;/blockquote&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/06/systemwebhostinghostingenvironmentexcep.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-666003774013114810</guid><pubDate>Thu, 12 Feb 2009 08:31:00 +0000</pubDate><atom:updated>2010-07-29T23:48:07.879+08:00</atom:updated><title>How to Register DLLs in C#</title><description>The &lt;strong&gt;Regsvr32&lt;/strong&gt; tool is used to register or un-register DLL or OCX files.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Usage&lt;/u&gt;:&lt;br /&gt;&lt;code&gt;Regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dll_name&lt;/code&gt;&lt;br /&gt;&lt;code&gt;/u&lt;/code&gt; – un-register server&lt;br /&gt;&lt;code&gt;/s&lt;/code&gt; – to run silently without display any message boxes&lt;br /&gt;&lt;code&gt;dll_name&lt;/code&gt; – indicates the path and file name of the DLL to register. More than one DLL is allowed in this command.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;:&lt;br /&gt;&lt;code&gt;regsvr32 C:\example.ocx&lt;br /&gt;regsvr32 /u C:\example.ocx&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sometimes we need to register DLLs programmatically, the codes below will show you how to invoke the &lt;strong&gt;regsvr32.exe &lt;/strong&gt;and register a dll file in C#.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;using&lt;/span&gt; System.Diagnostics;&lt;br /&gt;…&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;public static void&lt;/span&gt; registerDLL(&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; dllPath) &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;try&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#006600;&quot;&gt;//&#39;/s&#39; : indicates regsvr32.exe to run silently.&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; fileinfo = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;/s&quot;&lt;/span&gt; + &lt;span style=&quot;color:#660000;&quot;&gt;&quot; &quot;&lt;/span&gt; + &lt;span style=&quot;color:#660000;&quot;&gt;&quot;\&quot;&quot;&lt;/span&gt; + dllPath + &lt;span style=&quot;color:#660000;&quot;&gt;&quot;\&quot;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;Process&lt;/span&gt; reg = &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;Process&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.StartInfo.FileName = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;regsvr32.exe&quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.StartInfo.Arguments = fileinfo;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.StartInfo.UseShellExecute = &lt;span style=&quot;color:#000099;&quot;&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.StartInfo.CreateNoWindow = &lt;span style=&quot;color:#000099;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.StartInfo.RedirectStandardOutput = &lt;span style=&quot;color:#000099;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.Start();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.WaitForExit();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reg.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;catch&lt;/span&gt;(&lt;span style=&quot;color:#336666;&quot;&gt;Exception&lt;/span&gt; ex) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;MessageBox&lt;/span&gt;.Show(ex.Message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Hope this will help.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/02/how-to-register-dlls-in-c.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-8366565382641653214</guid><pubDate>Fri, 09 Jan 2009 06:45:00 +0000</pubDate><atom:updated>2010-07-29T23:45:25.151+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">excel</category><title>Error Message “No more new fonts may be applied in this workbook.” In Excel</title><description>I am currently working on a project, which I need to export an excel file with more than 100 charts need to be included. And guess what? Yeah…Microsoft Excel throws me this error when I tried to export data into the excel file:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;&lt;span style=&quot;color:#333333;&quot;&gt;No more new fonts may be applied in this workbook.&lt;/span&gt;&lt;/em&gt;&lt;/blockquote&gt;&lt;br /&gt;According to &lt;a href=&quot;http://support.microsoft.com/kb/215573/en-us&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;Microsoft Help and Support&lt;/strong&gt;&lt;/a&gt;, this problem is being caused because of the enabled &lt;strong&gt;Auto Scale&lt;/strong&gt; setting in my charts and textboxes (I am also adding textboxes in my excel file).&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;em&gt;&lt;span style=&quot;color:#333333;&quot;&gt;This problem occurs because of the &lt;strong&gt;Auto scale &lt;/strong&gt;setting. When you add a chart to the workbook, the Auto scale setting is enabled by default. This setting causes charts to use two or more fonts instead of one. When you add multiple charts to a workbook with this setting enabled, the font limitation for a workbook may be reached. &lt;br /&gt;&lt;br /&gt;For Microsoft Excel 2000 and later, the maximum number of fonts is 512. If you add charts manually or if you copy and paste existing charts, you can reach the font limitation for a workbook. The following is an example of copying existing charts:&lt;br /&gt;&lt;br /&gt;§ You create a chart object in the worksheet.&lt;br /&gt;§ You copy and paste the chart object on the same worksheet ten or more times.&lt;br /&gt;§ You then copy the worksheet several times in the same workbook.&lt;/span&gt;&lt;/em&gt;&lt;/blockquote&gt;&lt;br /&gt;So what I do is unchecked all the &lt;strong&gt;Auto Scale&lt;/strong&gt; checkbox in my charts and textboxes. And now I am able to export the data into excel file without any error. :)&lt;br /&gt;&lt;br /&gt;To disable &lt;strong&gt;Auto Scale&lt;/strong&gt; in charts or textboxes:&lt;br /&gt;1. Select a chart or textbox.&lt;br /&gt;2. For chart, right-click and select &lt;strong&gt;Format Chart Area&lt;/strong&gt;. For textbox, right-click and select &lt;strong&gt;Format Text Box&lt;/strong&gt;.&lt;br /&gt;3. Under the Font tab, deselect the &lt;strong&gt;Auto Scale&lt;/strong&gt; checkbox.&lt;br /&gt;4. Click &lt;strong&gt;OK&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;Cheers! :)&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2009/01/error-message-no-more-new-fonts-may-be.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-5049060794235769865</guid><pubDate>Wed, 31 Dec 2008 08:48:00 +0000</pubDate><atom:updated>2010-07-29T23:48:07.880+08:00</atom:updated><title>Write Data to SQL Server Tables Using SqlBulkCopy</title><description>&lt;p&gt;&lt;strong&gt;SqlBulkCopy&lt;/strong&gt; is a new feature in ADO .NET 2.0 that speed up a copy operation for a large amount of data from your .NET application to SQL Server tables.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;SqlBulkCopy&lt;/strong&gt; class can be used to write data only to SQL Server tables from different types of data source, as long as the data can be loaded to a &lt;strong&gt;DataTable&lt;/strong&gt; instance or read with an &lt;strong&gt;IDataReader&lt;/strong&gt; instance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SqlBulkCopy&lt;/strong&gt; contains an instance method &lt;strong&gt;WriteToServer&lt;/strong&gt;, which is used to transfer data from a source to the destination table. &lt;strong&gt;SqlBulkCopy&lt;/strong&gt; uses a collection of &lt;strong&gt;SqlBulkCopyColumnMapping&lt;/strong&gt; objects to map a column in a data source to a field in the destination table.&lt;br /&gt;&lt;br /&gt;There are some essential properties of &lt;strong&gt;SqlBulkCopy&lt;/strong&gt; that you should be aware of:&lt;br /&gt;&amp;nbsp;&amp;nbsp;§ BatchSize: Number of rows &lt;strong&gt;SqlBulkCopy&lt;/strong&gt; will copy from data source to the destination table.&lt;br /&gt;&amp;nbsp;&amp;nbsp;§ BulkCopyTimeOut: The number of seconds that system should wait to complete the copy operation.&lt;br /&gt;&amp;nbsp;&amp;nbsp;§ ColumnMappings: You can use its Add() method to add in a new &lt;strong&gt;SqlBulkCopyColumnMapping&lt;/strong&gt; object to its collection.&lt;br /&gt;&amp;nbsp;&amp;nbsp;§ DestinationTableName&lt;br /&gt;&amp;nbsp;&amp;nbsp;§ NotifyAfter: &lt;strong&gt;SqlRowsCopied&lt;/strong&gt; event handler will be triggered when the number of rows specified has been copied. This is very helpful if you want to be aware the progress of a copy operation, showing completed % in a progress bar, for example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;Sample Codes&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;Here, I will demonstrate how to import data from CSV source file into database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;…&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;br /&gt;…&lt;br /&gt;…&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;private void&lt;/span&gt; bulkCopy_SqlRowsCopied(&lt;span style=&quot;color:#000099;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color:#336666;&quot;&gt;SqlRowsCopiedEventArgs&lt;/span&gt; e) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;MessageBox&lt;/span&gt;.Show(&lt;span style=&quot;color:#336666;&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color:#660000;&quot;&gt;&quot;{0} rows have been copied.&quot;&lt;/span&gt;, e.RowsCopied.ToString()));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;private void&lt;/span&gt; CopyDataToDestinationTable()&lt;br /&gt;{ &lt;/code&gt;&lt;/p&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; strconn = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;&lt;br /&gt;server=localhost;Database=Transaction;User Id=sa;Password=123456;&quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;OleDbConnection&lt;/span&gt; conn = &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;OleDbConnection&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conn.ConnectionString = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\;Extended Properties=\&quot;text;HDR=Yes;FMT=CSVDelimited\&quot;&quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;try&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conn.Open();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;OleDbCommand&lt;/span&gt; myCommand = conn.CreateCommand();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; commandString = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;select * from source.csv&quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myCommand.CommandType = &lt;span style=&quot;color:#336666;&quot;&gt;CommandType&lt;/span&gt;.Text;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myCommand.CommandText = commandString;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;OleDbDataReader&lt;/span&gt; dataReader = myCommand.ExecuteReader();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dataReader.Read();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;using&lt;/span&gt; (&lt;span style=&quot;color:#336666;&quot;&gt;SqlBulkCopy&lt;/span&gt; bulkCopy = &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;SqlBulkCopy&lt;/span&gt;(strconn)) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.DestinationTableName = &lt;span style=&quot;color:#660000;&quot;&gt;&quot;Products&quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.BulkCopyTimeout = 100000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.NotifyAfter = 1000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.SqlRowsCopied += &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;SqlRowsCopiedEventHandler&lt;/span&gt;(bulkCopy_SqlRowsCopied);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.ColumnMappings.Add(&lt;span style=&quot;color:#660000;&quot;&gt;&quot;Brand&quot;&lt;/span&gt;, &lt;span style=&quot;color:#660000;&quot;&gt;&quot;Brand&quot;&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.ColumnMappings.Add(&lt;span style=&quot;color:#660000;&quot;&gt;&quot;Model&quot;&lt;/span&gt;, &lt;span style=&quot;color:#660000;&quot;&gt;&quot;Model&quot;&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.ColumnMappings.Add(&lt;span style=&quot;color:#660000;&quot;&gt;&quot;ProductName&quot;&lt;/span&gt;, &lt;span style=&quot;color:#660000;&quot;&gt;&quot;ProductName&quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#006600;&quot;&gt;// call WriteToServer which starts import&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bulkCopy.WriteToServer(dataReader);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;catch&lt;/span&gt; (&lt;span style=&quot;color:#336666;&quot;&gt;Exception&lt;/span&gt; ex) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;MessageBox&lt;/span&gt;.Show(ex.Message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;finally&lt;/span&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conn.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Well, that’s it. Feel free to ask if there is any problem. Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/12/write-data-to-sql-server-tables-using.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-7729610161016878745</guid><pubDate>Mon, 10 Nov 2008 13:45:00 +0000</pubDate><atom:updated>2008-11-10T21:51:26.595+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sql server</category><title>BULK INSERT in MS SQL SERVER</title><description>In IT environment, it is always a necessary to import data from data files into database.&lt;br /&gt;&lt;br /&gt;And recently, I have to deal with import a huge load of data (around 200 MB for 1 CSV input file) from CSV files into MS SQL SERVER. So what I had done to achieve this is by using BULK INSERT.&lt;br /&gt;&lt;br /&gt;Firstly, prepare a CSV data file with the following content and save as test.csv.&lt;br /&gt;&lt;code&gt;July,Singapore,25&lt;br /&gt;James,Australia,50&lt;br /&gt;May,China,29&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And then run scripts as following to load all the data from the CSV file into database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;--Temp table to store the data&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;CREATE TABLE&lt;/span&gt; CSVTest&lt;br /&gt;   (&lt;br /&gt; &amp;nbsp;&amp;nbsp; Name &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;VARCHAR&lt;/span&gt;(500),&lt;br /&gt; &amp;nbsp;&amp;nbsp; Country &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;VARCHAR&lt;/span&gt;(500),&lt;br /&gt; &amp;nbsp;&amp;nbsp; Age &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;INT&lt;/span&gt;&lt;br /&gt;)&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;--Bulk insert into CSVTest&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;BULK INSERT&lt;/span&gt; CSVTest&lt;br /&gt;  &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&#39;C:\test.csv&#39;&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;WITH&lt;/span&gt;&lt;br /&gt;     (&lt;br /&gt; &amp;nbsp;&amp;nbsp; FIELDTERMINATOR=&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&#39;,&#39;&lt;/span&gt;,&lt;br /&gt; &amp;nbsp;&amp;nbsp; ROWTERMINATOR = &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&#39;\n&#39;&lt;/span&gt;&lt;br /&gt;      )&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;--Get all data from CSVTest&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;SELECT&lt;/span&gt; *&lt;br /&gt;   &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;FROM&lt;/span&gt; CSVTest&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;--Drop the temp table&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;DROP TABLE&lt;/span&gt; CSVTest&lt;br /&gt;GO&lt;/code&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/11/bulk-insert-in-ms-sql-server.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-5648289338988922851</guid><pubDate>Mon, 03 Nov 2008 12:38:00 +0000</pubDate><atom:updated>2010-07-29T23:48:07.881+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>Kill Excel.exe Process in C# .NET</title><description>I am trying to get my C# .NET codes to generate reports into excel files. In the Export function, it creates the excel object, adds in the data and then saves the file.&lt;br /&gt;&lt;br /&gt;All of this works fine. But for some reason, the excel.exe process is still running when I check from task manager.&lt;br /&gt;&lt;br /&gt;I had tried to quit the excel application. I had tried to use &lt;code&gt;InteropServices.Marshal.ReleaseComObject&lt;/code&gt; to get rid of them in .NET. But unfortunately, the excel.exe is still sitting in memory.&lt;br /&gt;&lt;br /&gt;Finally, I found a way to kill the process in C# .NET. Take a look on the codes below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;using&lt;/span&gt; System.Diagnostics;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;using&lt;/span&gt; System.Collections;&lt;br /&gt;…&lt;br /&gt;…&lt;br /&gt;…&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Hashtable&lt;/span&gt; myHashtable;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;private void&lt;/span&gt; btnExport_Click(&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// get process ids before running the excel codes&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;CheckExcellProcesses();&lt;br /&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// export to excel&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;ExportDataToExcel();&lt;br /&gt; &lt;br /&gt; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// kill the right process after export completed&lt;/span&gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;KillExcel();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;private void&lt;/span&gt; ExportDataToExcel()&lt;br /&gt;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// your export process is here...&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;private void&lt;/span&gt; CheckExcellProcesses()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process[]&lt;/span&gt; AllProcesses = &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process&lt;/span&gt;.GetProcessesByName(&lt;span style=&quot;color: rgb(102, 0, 0);&quot;&gt;&quot;excel&quot;&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;myHashtable = &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Hashtable&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;int&lt;/span&gt; iCount = 0;&lt;br /&gt;          &lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;foreach&lt;/span&gt; ( &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process&lt;/span&gt; ExcelProcess &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;in&lt;/span&gt; AllProcesses) {   &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myHashtable.Add(ExcelProcess.Id, iCount);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iCount = iCount + 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}            &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;private void&lt;/span&gt; KillExcel()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process[]&lt;/span&gt; AllProcesses = &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process&lt;/span&gt;.GetProcessesByName(&lt;span style=&quot;color: rgb(102, 0, 0);&quot;&gt;&quot;excel&quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// check to kill the right process&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;foreach&lt;/span&gt; ( &lt;span style=&quot;color: rgb(51, 102, 102);&quot;&gt;Process&lt;/span&gt; ExcelProcess &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;in&lt;/span&gt; AllProcesses) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;if&lt;/span&gt; (myHashtable.ContainsKey(ExcelProcess.Id) == &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;false&lt;/span&gt;)&lt;br /&gt;                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExcelProcess.Kill();             &lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;AllProcesses = &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/11/kill-excelexe-process-in-c-net.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>37</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-1960805440066854583</guid><pubDate>Thu, 18 Sep 2008 01:24:00 +0000</pubDate><atom:updated>2010-07-29T23:43:17.266+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">AJAX</category><title>ASP .NET Validators don’t work properly with Update Panel</title><description>Recently I am working on a project ASP .NET AJAX. Of course it is very common to have some validators in some forms to control the input values, and unfortunately I experienced problem with validators inside the Update Panel. The validators just don’t work properly as I am expected.&lt;br /&gt;&lt;br /&gt;After google searching and here is the solution that I had found: &lt;a href=&quot;http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx&quot; target=&quot;_blank&quot;&gt;ASP .NET AJAX Validators&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Firstly, downloads the &lt;a href=&quot;http://blogs.msdn.com/mattgi/attachment/1516974.ashx&quot;&gt;validators.zip&lt;/a&gt; file and adds in the DLL into the /bin directory of your project. After that, include the following codes into the &lt;code&gt;pages&lt;/code&gt; section of the web.config.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;tagMapping&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.CompareValidator&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.CustomValidator&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.RangeValidator&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.RegularExpressionValidator&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.RequiredFieldValidator&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color:#ff0000;&quot;&gt;tagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;System.Web.UI.WebControls.ValidationSummary&lt;/span&gt;&quot; &lt;span style=&quot;color:#ff0000;&quot;&gt;mappedTagType&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0&lt;/span&gt;&quot;&lt;span style=&quot;color:#000099;&quot;&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#660000;&quot;&gt;tagMapping&lt;/span&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;And the problem solved. Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/09/asp-net-validators-dont-work-properly.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-7555157773740648971</guid><pubDate>Fri, 29 Aug 2008 06:41:00 +0000</pubDate><atom:updated>2010-07-29T23:46:22.721+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>OrElse and AndAlso operators in VB .NET</title><description>&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;OrElse&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt; are two new logical operators in VB .NET and they have some properties that can enhance your codes in two general categories:&lt;br /&gt;&lt;br /&gt;1. Avoid executing part of a logical expression.&lt;br /&gt;2. Optimize code by not executing any more of a compound expression than required.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;OrElse&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt; are quite similar with the &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;And&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Or&lt;/span&gt;&lt;/code&gt; except that VB .NET supports short-circuiting with the &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;OrElse&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt; operators. This means that the expressions will only be executed when necessary. Anyway, the &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;And&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Or&lt;/span&gt;&lt;/code&gt; are still present in VB .NET.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#006600;&quot;&gt;// Assume that str1 = 5,&lt;br /&gt;// x = 1 and y = 1&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;If&lt;/span&gt; x &gt; str1 &lt;span style=&quot;color:#000099;&quot;&gt;And&lt;/span&gt; y &amp;lt; str1 &lt;span style=&quot;color:#000099;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt; &lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#006600;&quot;&gt;&#39; code&lt;/span&gt; &lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End If&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When performing an &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;And&lt;/span&gt;&lt;/code&gt; operator in VB .NET, it actually evaluates both of the expressions to get the final outcome. Even the first condition (&lt;code&gt;x greater than str1&lt;/code&gt;) returns as &lt;span style=&quot;color:#000099;&quot;&gt;&lt;code&gt;FALSE&lt;/code&gt;&lt;/span&gt;, it still continues to look at the second argument even though it doesn’t need to.&lt;br /&gt;&lt;br /&gt;Let’s see how &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt; evaluates the codes below.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;If&lt;/span&gt; x &gt; str1 &lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt; y &amp;lt; str1 &lt;span style=&quot;color:#000099;&quot;&gt;Then&lt;/span&gt;&lt;/span&gt; &lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#006600;&quot;&gt;&#39; code&lt;/span&gt; &lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End If&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When using &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt;, VB .NET knows that the expression will not succeed once it is determined that the first condition (&lt;code&gt;x greater than str1&lt;/code&gt;) is &lt;span style=&quot;color:#000099;&quot;&gt;&lt;code&gt;FALSE&lt;/code&gt;&lt;/span&gt;. So it stops evaluating the expression right away without checking the second condition.&lt;br /&gt;&lt;br /&gt;The difference of &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Or&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;OrElse&lt;/span&gt;&lt;/code&gt; are also similar to &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;And&lt;/span&gt;&lt;/code&gt; and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;AndAlso&lt;/span&gt;&lt;/code&gt; operator, which &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Or&lt;/span&gt;&lt;/code&gt; will check all the conditions and &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;OrElse&lt;/span&gt;&lt;/code&gt; won’t checking the remaining expression, if it found any of the previous condition is &lt;span style=&quot;color:#000099;&quot;&gt;&lt;code&gt;TRUE&lt;/code&gt;&lt;/span&gt;.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/08/orelse-and-andalso-operators-in-vb-net.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-6217326086910502627</guid><pubDate>Tue, 19 Aug 2008 02:19:00 +0000</pubDate><atom:updated>2010-07-29T23:48:07.882+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>How to get Windows’ Serial Number and Windows Logon User Name in .NET</title><description>By using the namespace &lt;code&gt;System.Management&lt;/code&gt;, we can easily retrieve the serial number of your Windows OS and windows logon user name.&lt;br /&gt;&lt;br /&gt;First of all, you need to add a reference of &lt;code&gt;System.Management&lt;/code&gt; into your application. To add a reference into your .NET application, you can right-click on &lt;strong&gt;References&lt;/strong&gt; in the solution explorer and select &lt;strong&gt;Add Reference&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh67iYS6kJFYlKIEHNX37frIes_Lo7tApYa2Lh8REmxkJAzwqcUpM-kSlKDVS_IX8IfFei1LHXy3hYtfWhY_D_v3jjkQURb5uFTlyDXf8mXCM8EfELse2Su1aM8C4d2dRxz9xilO5Nh8VL6/s1600-h/Untitled-1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5236048752944321826&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh67iYS6kJFYlKIEHNX37frIes_Lo7tApYa2Lh8REmxkJAzwqcUpM-kSlKDVS_IX8IfFei1LHXy3hYtfWhY_D_v3jjkQURb5uFTlyDXf8mXCM8EfELse2Su1aM8C4d2dRxz9xilO5Nh8VL6/s200/Untitled-1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;From the &lt;strong&gt;Add References &lt;/strong&gt;dialog box, select &lt;code&gt;System.Management&lt;/code&gt; and click &lt;strong&gt;OK&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCUXQhOjX7BzJXyKjLXJFOOeRcu5dAOuA3vxmDCtPGL4NUV_aktzbmlhrvEVTDm9Huexdi2ZHsGELi0zbulcPh2c_QpA29C3U77tmr_Ra10jwE59dbmktW9jdaxkpJlfqQmUzP5ty8Y4O6/s1600-h/Untitled-1+copy.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5236048784135580226&quot; style=&quot;DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 212px; CURSOR: hand; HEIGHT: 173px; TEXT-ALIGN: center&quot; height=&quot;163&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCUXQhOjX7BzJXyKjLXJFOOeRcu5dAOuA3vxmDCtPGL4NUV_aktzbmlhrvEVTDm9Huexdi2ZHsGELi0zbulcPh2c_QpA29C3U77tmr_Ra10jwE59dbmktW9jdaxkpJlfqQmUzP5ty8Y4O6/s200/Untitled-1+copy.jpg&quot; width=&quot;201&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The sample codes below written in both C# and VB .NET show you how to read the Windows’ serial number and logon user name.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;C# .NET&lt;/u&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;using&lt;/span&gt; System.Management;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;public static string&lt;/span&gt; getSerialNumber() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; _serialNo = &lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectSearcher&lt;/span&gt; objMOS = &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectSearcher&lt;/span&gt;&lt;span style=&quot;color:#330000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#990000;&quot;&gt;&quot;Select * from Win32_OperatingSystem&quot;&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectCollection&lt;/span&gt; objMOC;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;objMOC = objMOS.Get();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObject&lt;/span&gt; objMO &lt;span style=&quot;color:#000099;&quot;&gt;in&lt;/span&gt; objMOC) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_serialNo = objMO[&lt;span style=&quot;color:#990000;&quot;&gt;&quot;SerialNumber&quot;&lt;/span&gt;].ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;return&lt;/span&gt; _serialNo;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;public static string&lt;/span&gt; getlogonUser(){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt; _user = &lt;span style=&quot;color:#000099;&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectSearcher&lt;/span&gt; objMOS = &lt;span style=&quot;color:#000099;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectSearcher&lt;/span&gt;(&lt;span style=&quot;color:#990000;&quot;&gt;&quot;SELECT * FROM Win32_ComputerSystem&quot;&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObjectCollection&lt;/span&gt; objMOC;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;objMOC = objMOS.Get();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color:#336666;&quot;&gt;ManagementObject&lt;/span&gt; objMO &lt;span style=&quot;color:#000099;&quot;&gt;in&lt;/span&gt; objMOC) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_user = objMO [&lt;span style=&quot;color:#990000;&quot;&gt;&quot;UserName&quot;&lt;/span&gt;].ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;return&lt;/span&gt; _user;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;VB .NET&lt;/u&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Imports&lt;/span&gt; System.Management&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Public Shared Function&lt;/span&gt; getSerialNumber() &lt;span style=&quot;color:#000099;&quot;&gt;As String&lt;br /&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; _serialNo &lt;span style=&quot;color:#000099;&quot;&gt;As String&lt;/span&gt; = &lt;span style=&quot;color:#000099;&quot;&gt;String&lt;/span&gt;.Empty&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; objMOS &lt;span style=&quot;color:#000099;&quot;&gt;As New&lt;/span&gt; ManagementObjectSearcher(&lt;span style=&quot;color:#990000;&quot;&gt;&quot;Select * from Win32_OperatingSystem&quot;&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; objMOC &lt;span style=&quot;color:#000099;&quot;&gt;As&lt;/span&gt; ManagementObjectCollection&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;objMOC = objMOS.Get&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;For Each&lt;/span&gt; objMO &lt;span style=&quot;color:#000099;&quot;&gt;As&lt;/span&gt; ManagementObject &lt;span style=&quot;color:#000099;&quot;&gt;In&lt;/span&gt; objMOC&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_serialNo = objMO(&lt;span style=&quot;color:#990000;&quot;&gt;&quot;SerialNumber&quot;&lt;/span&gt;).ToString()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Return&lt;/span&gt; _serialNo&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;Public Shared Function&lt;/span&gt; getlogonUser() &lt;span style=&quot;color:#000099;&quot;&gt;As String&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; _user &lt;span style=&quot;color:#000099;&quot;&gt;As String&lt;/span&gt; = &lt;span style=&quot;color:#000099;&quot;&gt;String&lt;/span&gt;.Empty&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; objMOS &lt;span style=&quot;color:#000099;&quot;&gt;As New&lt;/span&gt; ManagementObjectSearcher(&lt;span style=&quot;color:#990000;&quot;&gt;&quot;SELECT * FROM Win32_ComputerSystem&quot;&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Dim&lt;/span&gt; objMOC &lt;span style=&quot;color:#000099;&quot;&gt;As&lt;/span&gt; ManagementObjectCollection&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;objMOC = objMOS.Get&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;For Each&lt;/span&gt; objMO &lt;span style=&quot;color:#000099;&quot;&gt;As&lt;/span&gt; ManagementObject &lt;span style=&quot;color:#000099;&quot;&gt;In&lt;/span&gt; objMOC&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_user = objMO(&lt;span style=&quot;color:#990000;&quot;&gt;&quot;UserName&quot;&lt;/span&gt;).ToString()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#000099;&quot;&gt;Return&lt;/span&gt; _user&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;End Function&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Cheers.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/08/how-to-get-windows-serial-number-and.html</link><author>noreply@blogger.com (xiaoyu)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh67iYS6kJFYlKIEHNX37frIes_Lo7tApYa2Lh8REmxkJAzwqcUpM-kSlKDVS_IX8IfFei1LHXy3hYtfWhY_D_v3jjkQURb5uFTlyDXf8mXCM8EfELse2Su1aM8C4d2dRxz9xilO5Nh8VL6/s72-c/Untitled-1.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-5234733635448030326</guid><pubDate>Thu, 07 Aug 2008 13:36:00 +0000</pubDate><atom:updated>2010-07-29T23:48:07.883+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>Export Data to Excel (Not HTML Table) in C# .NET</title><description>In my previous post - &lt;a href=&quot;http://july-code.blogspot.com/2008/01/export-data-to-excel-not-html-tables.html&quot; target=_blank&gt;Export Data to Excel (Not HTML Tables)&lt;/a&gt;, I had shown you how to export to excel in VB .NET. &lt;br /&gt;&lt;br /&gt;In this post, I will use a C# .NET example instead.&lt;br /&gt;&lt;br /&gt;Of cause first thing that you need to do is to add &lt;strong&gt;Excel.dll&lt;/strong&gt; (&lt;strong&gt;Microsoft excel 11.0 Object Library&lt;/strong&gt;) into your .NET project references. &lt;br /&gt;&lt;br /&gt;Here is the codes:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:Blue;&quot;&gt;private void&lt;/span&gt; ExportToExcelFile(System.Data.DataTable dt)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Excel.Application xlsApp = &lt;span style=&quot;color:Blue;&quot;&gt;new&lt;/span&gt; Excel.ApplicationClass();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Excel.Workbook xlsWorkbook;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Excel.Worksheet xlsWorksheet;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;string&lt;/span&gt; strhdr;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;int&lt;/span&gt; row;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;string&lt;/span&gt; strFile = &quot;file1.xls&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;string&lt;/span&gt; filename = Server.MapPath(strFile);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;if&lt;/span&gt; (dt.Rows.Count &gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Create new workbook&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorkbook = xlsApp.Workbooks.Add(&lt;span style=&quot;color:Blue;&quot;&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Get the first worksheet&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet = (Excel.Worksheet)(xlsWorkbook.Worksheets[1]);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Activate current worksheet&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Activate();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Set header row to row 1&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row = 1;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Add table headers to worksheet&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 1] = &quot;Name&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 2] = &quot;Gender&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 3] = &quot;Age&quot;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Format header row (bold, extra row height, autofit width)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A&quot; + row.ToString(), &quot;C&quot; + row.ToString()).Font.Bold = &lt;span style=&quot;color:Blue;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A&quot; + row.ToString(), &quot;C&quot; + row.ToString()).Rows.RowHeight = 1.5 * xlsWorksheet.StandardHeight;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A&quot; + row.ToString(), &quot;C&quot; + row.ToString()).EntireRow.AutoFit();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Freeze the columm headers&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A&quot; + (row + 1).ToString(), &quot;C&quot; + (row + 1).ToString()).Select();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsApp.ActiveWindow.FreezePanes = &lt;span style=&quot;color:#009900;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Write data to Excel worksheet&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;foreach&lt;/span&gt; (DataRow dr &lt;span style=&quot;color:Blue;&quot;&gt;in&lt;/span&gt; dt.Rows)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row += 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;if&lt;/span&gt; (dr[&quot;Name&quot;] != &lt;span style=&quot;color:Blue;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 1] = dr[&quot;Name&quot;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;if&lt;/span&gt; (dr[&quot;Gender&quot;] != &lt;span style=&quot;color:Blue;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 2] = dr[&quot;Gender&quot;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:Blue;&quot;&gt;if&lt;/span&gt; (dr[&quot;Age&quot;] != &lt;span style=&quot;color:Blue;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.Cells[row, 3] = dr[&quot;Age&quot;];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Format data rows (align to center and left, autofit width and height)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A2&quot;, &quot;C&quot; + row.ToString()).VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A2&quot;, &quot;C&quot; + row.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A2&quot;, &quot;c&quot; + row.ToString()).EntireColumn.AutoFit();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorksheet.get_Range(&quot;A2&quot;, &quot;c&quot; + row.ToString()).EntireRow.AutoFit();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Make excel workbook visible to user after all data has been added to worksheet.&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsApp.DisplayAlerts = &lt;span style=&quot;color:Blue;&quot;&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xlsWorkbook.Close(&lt;span style=&quot;color:Blue;&quot;&gt;true&lt;/span&gt;, filename, &lt;span style=&quot;color:Blue;&quot;&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#009900;&quot;&gt;//Export data to client machine&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;strhdr = &quot;attachment;filename=&quot; + strFile;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Clear();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.ContentType = &quot;application/vnd.ms-excel&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.ContentEncoding = System.Text.Encoding.Default;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.AppendHeader(&quot;Content-Disposition&quot;,strhdr);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.WriteFile(filename);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Flush();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Clear();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/08/export-data-to-excel-not-html-table-in.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>12</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-1251763987548224486</guid><pubDate>Thu, 31 Jul 2008 03:55:00 +0000</pubDate><atom:updated>2008-07-31T12:06:56.885+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sql server</category><title>How to Insert Value into an Identity Column</title><description>In database tables, normally identity columns are used as primary keys that automatically generates numeric values for every new inserted row.&lt;br /&gt;&lt;br /&gt;For this identity (AutoNumber) column, you are not allow to insert your own value. So what if you really want to insert your own value into the column?&lt;br /&gt;&lt;br /&gt;A very easy way to do this. I will show you how to do this.&lt;br /&gt;&lt;br /&gt;Firstly, create a table &lt;code&gt;Sample&lt;/code&gt; by using the script below into your database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;CREATE TABLE&lt;/span&gt; Sample (&lt;br /&gt;Id &lt;span style=&quot;color:#000099;&quot;&gt;INT&lt;/span&gt; NOT NULL &lt;span style=&quot;color:#000099;&quot;&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span style=&quot;color:#000099;&quot;&gt;PRIMARY KEY&lt;/span&gt;,&lt;br /&gt;Name VARCHAR(50) NOT NULL )&lt;br /&gt;GO&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Normally if we want to insert a new row into this table, you will have to only insert the value of &lt;code&gt;Name&lt;/code&gt;, as script below:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;INSERT INTO&lt;/span&gt; Sample(Name) &lt;span style=&quot;color:#000099;&quot;&gt;VALUES&lt;/span&gt; (&#39;July&#39;)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Now, we try to insert a value into the &lt;code&gt;Id&lt;/code&gt; column.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;INSERT INTO&lt;/span&gt; Sample(Id, Name) &lt;span style=&quot;color:#000099;&quot;&gt;VALUES&lt;/span&gt; (11, &#39;July&#39;)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When this query is executed, an error will be generated:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Msg 544, Level 16, State 1, Line 1&lt;br /&gt;Cannot insert explicit value for identity column in table &#39;Sample&#39; when IDENTITY_INSERT is set to OFF.&lt;/span&gt;&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;To insert this record into table without any error, you just need to enable the &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;IDENTITY_INSERT&lt;/span&gt;&lt;/code&gt;. It should look like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET IDENTITY_INSERT&lt;/span&gt; Sample &lt;span style=&quot;color:#000099;&quot;&gt;ON&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;INSERT INTO&lt;/span&gt; Sample(Id, Name) &lt;span style=&quot;color:#000099;&quot;&gt;VALUES&lt;/span&gt; (11, &#39;July&#39;)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET IDENTITY_INSERT&lt;/span&gt; Sample &lt;span style=&quot;color:#000099;&quot;&gt;OFF&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;But there are some points that you need to be aware of about &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;IDENTITY_INSERT&lt;/span&gt;&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;1.&amp;nbsp;&amp;nbsp; Only 1 table can have the &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;IDENTITY_INSERT&lt;/span&gt;&lt;/code&gt; property set to &lt;code&gt;ON&lt;/code&gt; at a time. If you try to enable &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;IDENTITY_INSERT&lt;/span&gt;&lt;/code&gt; to &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;ON&lt;/span&gt;&lt;/code&gt; for a second table while a &lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET IDENTITY_INSERT ON&lt;/span&gt;&lt;/code&gt; statement is issued for another table, SQL Server will return an error message.&lt;br /&gt;2. &amp;nbsp;&amp;nbsp; If the value that you have inserted is greater than the current identity seed in your table, the new inserted value will be set as the current identity seed.&lt;br /&gt;&lt;br /&gt;For example, table &lt;code&gt;Sample&lt;/code&gt; has its current identity value 1 and you want to insert a new row with the identity value 11. When you insert another new row, your identity value will start from 12, instead of 1.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET IDENTITY_INSERT&lt;/span&gt; Sample &lt;span style=&quot;color:#000099;&quot;&gt;ON&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;INSERT INTO&lt;/span&gt; Sample(Id, Name) &lt;span style=&quot;color:#000099;&quot;&gt;VALUES&lt;/span&gt; (11, &#39;July&#39;)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;SET IDENTITY_INSERT&lt;/span&gt; Sample &lt;span style=&quot;color:#000099;&quot;&gt;OFF&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000099;&quot;&gt;INSERT INTO&lt;/span&gt; Sample(Name) &lt;span style=&quot;color:#000099;&quot;&gt;VALUES&lt;/span&gt; (&#39;August&#39;)&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;Id Name&lt;br /&gt;11 July&lt;br /&gt;12 August&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Cheers.&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/code&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/07/how-to-insert-value-into-identity.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-3437159899434806237</guid><pubDate>Fri, 25 Jul 2008 13:18:00 +0000</pubDate><atom:updated>2010-08-22T11:21:53.674+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">AJAX</category><category domain="http://www.blogger.com/atom/ns#">javascript</category><category domain="http://www.blogger.com/atom/ns#">web service</category><title>How to Call Remote Web Services from Client Side JavaScript</title><description>Web Services is a collection of universally available functions, which allows different applications from different sources to share among each other without time-consuming custom coding by using the XML, SOAP, WSDL and UDDI open standards across the Internet. You can go to &lt;a href=&quot;http://www.webopedia.com/TERM/W/Web_services.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; for more detail explanation on it.&lt;br /&gt;&lt;br /&gt;Recently, I have been doing some research into how to call a web service from client side JavaScript. ASP .NET AJAX enables you to call a web service from the browser by using client script, namely the page can call server-based methods without a postback and refreshing the whole web page.&lt;br /&gt;&lt;br /&gt;Here, I will show you how to call Web Services within the same project and also how to call Web Services remotely.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Consuming a Local Web Service&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;Simple example of Web Service&lt;/u&gt;&lt;br /&gt;I assume that you had installed the ASP .NET AJAX framework. So let us start with create a new &lt;b&gt;ASP .NET AJAX-Enabled Web Application&lt;/b&gt; created.&lt;br /&gt;&lt;br /&gt;I will firstly show you how to call a web service within the same project, so let’s add new Web Service called &lt;b&gt;webService.asmx&lt;/b&gt; to the project (Right-click your project on your solution explorer | &lt;b&gt;Add New Item&lt;/b&gt; | Select &lt;b&gt;Web Service&lt;/b&gt; and name it | Click &lt;b&gt;Add&lt;/b&gt;.).&lt;br /&gt;&lt;br /&gt;Let us create a very simple web service that returns current date and time.&lt;br /&gt;&lt;br /&gt;In order to make a web service accessible from script, the web service class must be qualified with the &lt;b&gt;ScriptServiceAttribute&lt;/b&gt;. See the example below:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;...&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;using&lt;/span&gt; System.Web.Script.Services;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;[&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebService&lt;/span&gt;(Namespace = &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;http://tempuri.org/&quot;&lt;/span&gt;)]&lt;br /&gt;[&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebServiceBinding&lt;/span&gt;(ConformsTo = &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WsiProfiles&lt;/span&gt;.BasicProfile1_1)]&lt;br /&gt;&lt;b&gt;[&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;ScriptService&lt;/span&gt;]&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;public class&lt;/span&gt; &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebService&lt;/span&gt; : System.Web.Services.&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebService&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebMethod&lt;/span&gt;]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;public string&lt;/span&gt; GetCurrentDateTime() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;string&lt;/span&gt; curTime = &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;Current datetime is {0}.&quot;&lt;/span&gt;, &lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;DateTime&lt;/span&gt;.Now);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;return&lt;/span&gt; curTime;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And then save it.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Exposing Web Services to Client Script in .aspx Web Page&lt;/u&gt;&lt;br /&gt;To enable a web service to be called from client script in your .aspx file, make sure that we have one instance of &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;object.&lt;br /&gt;&lt;br /&gt;Then add the &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;Services&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;collection to the &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;object, reference the web service by adding &lt;code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ServiceReference&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;child element to the &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;Services&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;collection and sets its &lt;code style=&quot;color: rgb(255, 0, 0);&quot;&gt;Path&lt;/code&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt; &lt;/span&gt;attribute to point to the web service. Below is how it is looks like:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt; &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(51, 51, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;ScriptManager1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Services&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ServiceReference  &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Path&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;WebService.asmx&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Services&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Client-side Function, Button and Label&lt;/u&gt;&lt;br /&gt;Next we need to add in a client-side function to call server-side web service, a button to trigger the web service, and a label to display the returned result. Below is the sample of the web page:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;head &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;Calling Web Services&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;script &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;language&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;GetTime() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;WebService.GetCurrentDateTime(ShowResult);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;ShowResult(result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;document.getElementById(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;lblResult&quot;&lt;/span&gt;).innerHTML = result.value;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Label &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;lblResult&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;Result will be displayed here.&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;:&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Label&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;btn&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;btn&quot; &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;GetTime()&quot;&amp;gt;&lt;/span&gt;Get Time&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&amp;amp;&lt;/span&gt;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;TIPS: If you want to call the JavaScript function from a separate .js file, copy the functions into the .js file, and the add in &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;Scripts&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;collection to the &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;object, reference the JavaScript function by adding &lt;code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptReference&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;child element to the &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;Scripts&lt;/code&gt;&lt;span style=&quot;color: rgb(102, 102, 102);&quot;&gt; &lt;/span&gt;collection and sets its &lt;code style=&quot;color: rgb(255, 0, 0);&quot;&gt;Path&lt;/code&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt; &lt;/span&gt;attribute to point to the JavaScript, as below:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Scripts&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;:&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptReference &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Path&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;CallWebServiceMethods.js&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Scripts&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;That’s it for consuming web service, which located in the same project.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Consuming Web Services Remotely&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;&lt;u&gt;WebService Behavior (HTC file)&lt;/u&gt;&lt;br /&gt;The first thing that you need to do is to create a separate &lt;b&gt;ASP .NET Web Service application&lt;/b&gt; and copy the web service that we created as above into it. I will add another method here to show you how to call a web service and pass parameters to its method through JavaScript.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;[&lt;span style=&quot;color: rgb(51, 153, 153);&quot;&gt;WebMethod&lt;/span&gt;]&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;public string&lt;/span&gt; EchoYourWord(&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;string&lt;/span&gt; yourword) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;return &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;You have said that: &quot;&lt;/span&gt; + yourword;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Save and run it. So now you got your web service ready to test.&lt;br /&gt;&lt;br /&gt;WebService behavior enables us to make a method call to a remote web service using a scripted language. It is a reusable DHTML component that uses web services by handling the communication of the SOAP data packets between the browser and the web services.&lt;br /&gt;&lt;br /&gt;The following are 3 important methods supported by the web service behavior:&lt;br /&gt;&lt;ul&gt;   &lt;li&gt;createUseOptions – Allows us to preserve authentication information across remote method invocations. Can be very useful when using SSL to communicate with the remote web service&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt;   &lt;li&gt;callService – Allows us to invoke the remote web service method asynchronously&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt;   &lt;li&gt;useService – Allows us to establish a friendly name for the web service that can be used while invoking the web service&lt;/li&gt; &lt;/ul&gt; You can download the HTC file at &lt;a href=&quot;http://msdn.microsoft.com/downloads/samples/internet/behaviors/library/webservice/default.asp&quot; target=_blank&gt;here&lt;/a&gt;. Copy into the same folder as your project.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;How to use Web Service Behavior in .aspx Page&lt;/u&gt;&lt;br /&gt;I will recommend you that to create another new .aspx page to test on consuming remote web service.&lt;br /&gt;&lt;br /&gt;To invoke the &lt;code&gt;GetCurrentDateTime()&lt;/code&gt; method, we have to attach the HTC file to a valid element, such as DIV or BODY.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;div &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;service&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;BEHAVIOR:url(webservice.htc)&quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Once this behavior is attached, we may need to add some code to the web page to enable use of WebService behavior and make calls to the web service.&lt;br /&gt;&lt;br /&gt;Add in this JavaScript function, as below:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;Init() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// initialize and create a name &quot;webService&quot; for Web service&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Note: the &quot;service.use...&quot; is the DIV or BODY element’s id as created just now.&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;service.useService(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;http://localhost/My_WebServices/WebService.asmx?wsdl&quot;&lt;/span&gt;,  &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;webService&quot;&lt;/span&gt;);&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Next, we will need to invoke the &lt;code&gt;useService&lt;/code&gt; method in the &lt;code style=&quot;color: rgb(255, 0, 0);&quot;&gt;onload&lt;/code&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt; &lt;/span&gt;event to map the web service before any methods on the web service are invoked.&lt;br /&gt;&lt;br /&gt;After that, we can add in another JavaScript function and use the &lt;code&gt;callService&lt;/code&gt; method to invoke the remote web service method asynchronously.&lt;br /&gt;&lt;br /&gt;Your web page should look like this when you are done:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;head &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;Calling Web Services&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;script &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;language&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;Init() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// initialize and create a shortcut name &quot;webService&quot; for Web service&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Note: the &quot;service.use...&quot; is the DIV or BODY element’s id as created just now.&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;service.useService(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;http://localhost/My_WebServices/WebService.asmx?wsdl&quot;&lt;/span&gt;,  &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;webService&quot;&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;GetTime() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// Note: the &quot;service.webService...&quot; is the shortcut name of your web service that you had initialize in the Init().&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;service.webService.callService(ShowResult, &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;GetCurrentDateTime&quot;&lt;/span&gt;);      &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 153, 0);&quot;&gt;// sample of passing a parameter to the web service&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;var &lt;/span&gt;myword;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;Echo() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;myword = document.form1.SayOutLoud.value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;service.webService.callService(ShowResult, &lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;EchoYourWord&quot;&lt;/span&gt;, myword);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;function &lt;/span&gt;ShowResult(result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;document.getElementById(&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;&quot;lblResult&quot;&lt;/span&gt;).innerHTML = result.value;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;onload&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;Init()&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;form1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt; &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;div &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;service&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;BEHAVIOR:url(webservice.htc)&quot; &amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Label &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;lblResult&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;Result will be displayed here.&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;Label&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Your words : &lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;input &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;text&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;SayOutLoud&quot;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;btn&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;btn&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;GetTime()&quot;&amp;gt;&lt;/span&gt;Get Time&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;btn1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&quot;btn1&quot;&lt;/span&gt; &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;onclick&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;=&quot;Echo()&quot;&amp;gt;&lt;/span&gt;Echo Your Word&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;br&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 153);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: Of course, if you are using a separate .js file, you still need to add a reference in a &lt;code style=&quot;color: rgb(153, 0, 0);&quot;&gt;ScriptManager&lt;/code&gt;&lt;span style=&quot;color: rgb(153, 0, 0);&quot;&gt; &lt;/span&gt;object, as I had mentioned above.&lt;br /&gt;&lt;br /&gt;That’s it for calling a remote web service. Any question please feels free to ask.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/07/how-to-call-remote-web-services-from.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-3110073340782976688</guid><pubDate>Fri, 11 Jul 2008 07:53:00 +0000</pubDate><atom:updated>2011-04-12T11:14:40.302+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB</category><title>Displaying Date and time in VB Script with ASP Classic</title><description>To display the Date and Time in your ASP page with certain format is very simple indeed. Take a look at the examples as below:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=time()%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Get current time &lt;dt&gt;&lt;dd&gt;- e.g. 9:52:30 AM&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=date()%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Get current date &lt;dt&gt;&lt;dd&gt;- e.g. 7/11/2008&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=now()%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Get current date and time &lt;dt&gt;&lt;dd&gt;- e.g. 7/11/2008 9:54:03 AM&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=FormatDateTime(now,0)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. 7/11/2008 9:55:41 AM&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=FormatDateTime(now,1)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. Friday, July 11, 2008&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=FormatDateTime(now,2)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. 7/11/2008&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=FormatDateTime(now,3)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. 9:57:49 AM&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=FormatDateTime(now,4)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. 09:58&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=WeekDay(now)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Day of the week &lt;dt&gt;&lt;dd&gt;- e.g. 6&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=WeekDayName(WeekDay(now))%&amp;gt; &lt;/code&gt;&lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. Friday&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Day(date)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Day of the month &lt;dt&gt;&lt;dd&gt;- e.g. 11&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Month(date)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Month of the year &lt;dt&gt;&lt;dd&gt;- e.g. 7&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=MonthName(Month(date))%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- e.g. July&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Year(date)%&amp;gt;&lt;/code&gt; &lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Current year &lt;dt&gt;&lt;dd&gt;- e.g. 2008&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Right(Year(date),2)%&amp;gt; &lt;/code&gt;&lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Current year &lt;dt&gt;&lt;dd&gt;e.g. 08&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Hour(now)%&amp;gt; &lt;/code&gt;&lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Hour part &lt;dt&gt;&lt;dd&gt;- e.g. 10&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Minute(now)%&amp;gt; &lt;/code&gt;&lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Minute part &lt;dt&gt;&lt;dd&gt;- e.g. 11&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;%=Second(now)%&amp;gt; &lt;/code&gt;&lt;dl&gt;&lt;dt&gt;&lt;dd&gt;- Second part &lt;dt&gt;&lt;dd&gt;- e.g. 2&lt;/dd&gt;&lt;/dl&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Hope you will find this helpful.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/07/displaying-date-and-time-in-vb-script.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4981218661818789875.post-1589024033191998221</guid><pubDate>Thu, 19 Jun 2008 10:38:00 +0000</pubDate><atom:updated>2010-07-29T23:43:17.272+08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><title>Couldn’t find ConfigurationManager in System.Configuration?</title><description>I am trying to pull an &lt;code&gt;appSettings&lt;/code&gt; key from my web.config. In .NET 1.1, we usually use:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;System.Configuration.&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationSettings&lt;/span&gt;.AppSettings[&lt;span style=&quot;color:#660000;&quot;&gt;&quot;strConnection&quot;&lt;/span&gt;].ToString();&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;However, in .NET2.0, using this code will cause the following error:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&#39;System.Configuration.&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationSettings&lt;/span&gt;.AppSettings&#39; is obsolete: &#39;This method is obsolete, it has been replaced by System.Configuration!System.Configuration.&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationManager&lt;/span&gt;.AppSettings&#39;&lt;/code&gt;&lt;/blockquote&gt;So I just change my code to the following, according to the error above. But the problem is I can’t find &lt;code&gt;&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationManager&lt;/span&gt;&lt;/code&gt; in the &lt;code&gt;System.Configuration&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;The reason is because the original &lt;code&gt;System.Configuration.&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationSettings&lt;/span&gt;&lt;/code&gt; class is point to the &lt;code&gt;System.dll&lt;/code&gt; assembly. There is another new the &lt;code&gt;System.Configuration.dll&lt;/code&gt; assembly with the new &lt;code&gt;&lt;span style=&quot;color:#336666;&quot;&gt;ConfigurationManager&lt;/span&gt;&lt;/code&gt; class. In this case, you need to add in the &lt;code&gt;System.Configuration.dll&lt;/code&gt; as a reference to your application before you can use it.&lt;br /&gt;&lt;br /&gt;Hope this will help someone.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;p&gt;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/feed-icon16x16.png&quot; alt=&quot;&quot; style=&quot;vertical-align:middle;border:0&quot;/&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://feeds.feedburner.com/CodeLibraryOfE-july&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;Subscribe in a reader&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><link>http://july-code.blogspot.com/2008/06/couldnt-find-configurationmanager-in.html</link><author>noreply@blogger.com (xiaoyu)</author><thr:total>3</thr:total></item></channel></rss>