<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12419046</id><updated>2011-11-30T02:27:16.279-08:00</updated><category term='.NET business connector'/><category term='Windows app'/><category term='CSV Files'/><category term='Microsoft Dynamics AX'/><category term='Axapta'/><title type='text'>Lakshmi's articles on .NET</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12419046.post-8724728144301077284</id><published>2010-12-10T01:46:00.000-08:00</published><updated>2010-12-10T01:46:53.290-08:00</updated><title type='text'>ASP.NET : "Only one usage of each socket address (protocol/network address/port) is normally permitted"</title><content type='html'>&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;You might get an error "Only one usage of each socket address (protocol/network address/port) is normally permitted" when trying to run an ASP.NET application. This might happen when you either have muliple apps using the same port in Casinini web server or when you have many ASP.NET apps running simultaneously.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;For a workaround, use the following steps:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;1. Close the ASP.NET solution in Visual Studio.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;2. Navigate to the folder containing the Project file of the ASP.NET application.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;3. Right click on the Project file of the ASP.NET project (the one with extension (.csproj))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;4. Do a Find for "&lt;autoassignport&gt;" tag. Change the value to "False".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;5. Rename the "&lt;developmentserverport&gt;" also with a different number if you wish.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;6. Save the file and close it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Now open the ASP.NET solution again and try to run your app. You'll now be able to run the application without the error quoted above.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Cheers!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-8724728144301077284?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/8724728144301077284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=8724728144301077284&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/8724728144301077284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/8724728144301077284'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2010/12/aspnet-only-one-usage-of-each-socket.html' title='ASP.NET : &quot;Only one usage of each socket address (protocol/network address/port) is normally permitted&quot;'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-6120633907403115815</id><published>2010-12-05T23:04:00.000-08:00</published><updated>2010-12-05T23:04:57.047-08:00</updated><title type='text'>Parallelism : Parallel Extensions in .NET 4.0</title><content type='html'>&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Recently I had attended a conference on Parallelism and Parallel Extensions in .NET 4.0. The whole concept seems to be really interesting and exciting and its all about how we effectively use CPU in multi-core systems at the level of programming. And yes, it solves the most oft come across problems in large solutions -&amp;nbsp;the Performance issue.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;I've just started my journey into it - exploring the whole lot of samples here:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://code.msdn.microsoft.com/ParExtSamples"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;http://code.msdn.microsoft.com/ParExtSamples&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;And this is not just for .NET - and&amp;nbsp;Parallelism is used in&amp;nbsp;SQL as well. There are some &lt;span lang="EN-US" style="color: #1f497d; font-family: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-latin;"&gt;&lt;a href="http://support.microsoft.com/kb/329204"&gt;General guidelines&lt;/a&gt; &lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;for Maximum degree of Parallelism in SQL Server&amp;nbsp; and &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms188611.aspx"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Degree of Parallelism&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt; concepts which you might also be interested in.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span lang="EN-US" style="color: #1f497d; font-family: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-latin;"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Hope you also find this interesting and exciting that can be used in your projects to improve your business as well.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span lang="EN-US" style="color: #1f497d; font-family: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-latin;"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span lang="EN-US" style="color: #1f497d; font-family: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-latin;"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Cheers!&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span lang="EN-US" style="color: #1f497d; font-family: &amp;quot;Calibri&amp;quot;, &amp;quot;sans-serif&amp;quot;; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-IN; mso-fareast-theme-font: minor-latin;"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-6120633907403115815?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/6120633907403115815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=6120633907403115815&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/6120633907403115815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/6120633907403115815'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2010/12/parallelism-parallel-extensions-in-net.html' title='Parallelism : Parallel Extensions in .NET 4.0'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-9162833759807126948</id><published>2010-12-05T22:43:00.000-08:00</published><updated>2010-12-05T22:43:08.696-08:00</updated><title type='text'>Visual Studio 2010 : Unexpected error writing metadata to file '.exe' -- 'Not enough storage is available to complete this operation.'</title><content type='html'>&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt; &lt;/span&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;You might get an error "&lt;span style="color: red;"&gt;Unexpected error writing metadata to file '&lt;appe name=""&gt;.exe' - 'Not enough storage is available to complete this operation.&lt;/span&gt;" when you build with Visual Studio 2010. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Well ,sometime back we had a migration to using Visual Studio Team system from using Source depot. Incidently this was the I was building my app after the&amp;nbsp;migration and setup of VSTS. When trying build the app, I was getting the above error which was delaying my work for almost an entire day. I had sufficient hard disc and memory space - as opposed to what the message said. "Binging" didn't help much.. several sites suggested to re-install VS 2010. However, I was little skeptical in doing a re-install as I was almost for sure knew there was nothing wrong with my VS installation.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;I randomly tried several options -luckily one of that fixed the issue. So for anyone else having the same issue - here are the steps - which you may want to try, if your Source control uses VSTS:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;1. Check the path that contains your Project.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;2. In Team explorer, click Source control.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;3. In Source control explorer, right click on the folder of&amp;nbsp;your project that gives the above error and click "Remove mapping".&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_owLhoazlDq8/TPyFUAsFQgI/AAAAAAAABVA/64n_MxF2fN0/s1600/TFS.jpg" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;img border="0" height="320" ox="true" src="http://2.bp.blogspot.com/_owLhoazlDq8/TPyFUAsFQgI/AAAAAAAABVA/64n_MxF2fN0/s320/TFS.jpg" width="163" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;4. This removes any connection of that folder of your project with VSTS. This might take a few minutes if your project is large.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;5. Create a new folder and map your project to the new folder by taking the latest from TFS.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;6. Build your project. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;This should solve the above&amp;nbsp;issue. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Cheers!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #073763; font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-9162833759807126948?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/9162833759807126948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=9162833759807126948&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/9162833759807126948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/9162833759807126948'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2010/12/visual-studio-2010-unexpected-error.html' title='Visual Studio 2010 : Unexpected error writing metadata to file &apos;&lt;appe name&gt;.exe&apos; -- &apos;Not enough storage is available to complete this operation.&apos;'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_owLhoazlDq8/TPyFUAsFQgI/AAAAAAAABVA/64n_MxF2fN0/s72-c/TFS.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-4080839498069681027</id><published>2010-10-06T10:05:00.001-07:00</published><updated>2010-10-06T10:05:55.801-07:00</updated><title type='text'>Test post</title><content type='html'>&lt;p&gt;This is a test post&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-4080839498069681027?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/4080839498069681027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=4080839498069681027&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/4080839498069681027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/4080839498069681027'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2010/10/test-post.html' title='Test post'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-7811505815490855904</id><published>2009-06-02T04:56:00.000-07:00</published><updated>2009-06-02T06:02:22.801-07:00</updated><title type='text'>SQL: Executing a set of queries with different parameters in a loop</title><content type='html'>It has been quite long time since I did lot of SQL queries and recently had to get myself in one such task. There were some long set of queries to be executed in a loop that is supposed to run for around 50 times with different set of results.&lt;br /&gt;With some search/research I found a quick solution using SQL Cursors and thought of sharing the same.&lt;br /&gt;Example:&lt;br /&gt;The scenario was as below:&lt;br /&gt;&lt;br /&gt;DECLARE @Var1 NVARCHAR(100)&lt;br /&gt;&lt;br /&gt;SET @Var1 = 'Some value'&lt;br /&gt;&lt;br /&gt;SELECT VALUES FROM TABLENAME WHERE VALUE = @Var1&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;...-- many other similar queries using the value of @Var1&lt;br /&gt;&lt;br /&gt;The challenge was to keep setting the @Var1 variable with 50 or more different values to get different set of results.&lt;br /&gt;Instead of executing the above queries 50 odd times, the following steps could be used for once instead to achieve the same results:&lt;br /&gt;&lt;br /&gt;1. The first step is to get the 50 or more odd values into a table using a condition that could be used further:&lt;br /&gt;SELECT * INTO SETOFVALUESTABLE FROM SOMETABLE WHERE -- CONDITION&lt;br /&gt;&lt;br /&gt;2. Next step is to declare a cursor that could accomplish our task:&lt;br /&gt;&lt;br /&gt;DECLARE @Var1 NVARCHAR(100)&lt;br /&gt;&lt;br /&gt;DECLARE db_cursor CURSOR FOR&lt;br /&gt;SELECT COLUMNNAME FROM SETOFVALUESTABLE&lt;br /&gt;&lt;br /&gt;OPEN db_cursor&lt;br /&gt;FETCH NEXT FROM db_cursor INTO @Var1&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;SELECT VALUES FROM TABLENAME WHERE VALUE = @Var1&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;...-- many other similar queries using the value of @Var1&lt;br /&gt;&lt;br /&gt;FETCH NEXT FROM db_cursor INTO @Var1&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;CLOSE db_cursor&lt;br /&gt;DEALLOCATE db_cursor&lt;br /&gt;&lt;br /&gt;Using the above steps saved me a lot of time and made it so simple and productive instead of the 50+ times execution of queries.&lt;br /&gt;&lt;br /&gt;There might still be better efficient ways to achieve the same with which I plan to optimize, but the above method is one quick way to get around the problem we faced.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-7811505815490855904?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/7811505815490855904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=7811505815490855904&amp;isPopup=true' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/7811505815490855904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/7811505815490855904'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2009/06/sql-executing-set-of-queries-with.html' title='SQL: Executing a set of queries with different parameters in a loop'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-7679112788065473959</id><published>2008-09-15T07:36:00.000-07:00</published><updated>2009-01-09T01:57:37.922-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Axapta'/><category scheme='http://www.blogger.com/atom/ns#' term='Microsoft Dynamics AX'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET business connector'/><title type='text'>HOW TO: Connect to AX 4.0 from a .NET Application using Business connector</title><content type='html'>This article demonstrates how a we can connect to Microsoft Dynamics AX 4.0 from a .NET based application.&lt;br /&gt;&lt;br /&gt;You can find a good explanation of Microsoft Dynamics AX from &lt;a href="http://msdn.microsoft.com/en-us/dynamics/ax/default.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For this you will need to have Microsoft Dynamics AX Client installed on your machine. You must also have Dynamics AX .NET Business connector installed on your machine - to connect to AX from .NET.&lt;br /&gt;&lt;br /&gt;Once you have the client components installed, you must configure your client to connect to an Axapta server from Control panel -&gt; Administrative tools -&gt;Microsoft Dynamics AX Configuration Utility.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_owLhoazlDq8/SRFtcc9RRtI/AAAAAAAAAAM/TtKCya2KYxU/s1600-h/configtool.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5265109774949762770" style="FLOAT: middle; MARGIN: 0px 10px 10px 0px; WIDTH: 289px; CURSOR: hand; HEIGHT: 320px" alt="" src="http://2.bp.blogspot.com/_owLhoazlDq8/SRFtcc9RRtI/AAAAAAAAAAM/TtKCya2KYxU/s320/configtool.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br/&gt;Once configured, you can open the AX client UI from Start-&gt; Programs-&gt; Microsoft Dynamics AX.&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_owLhoazlDq8/SRFu2pG2XFI/AAAAAAAAAAU/2b-LYm5kYA4/s1600-h/AXUI.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5265111324399393874" style="FLOAT: middle; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 223px" alt="" src="http://4.bp.blogspot.com/_owLhoazlDq8/SRFu2pG2XFI/AAAAAAAAAAU/2b-LYm5kYA4/s320/AXUI.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Lets now see how to invoke a simple method in AX from a .NET application.&lt;br /&gt;&lt;br /&gt;The following method should be written in AX inorder to be invoked from .NET:&lt;br /&gt;1. Navigate to AX UI&lt;br /&gt;2. Click on Axapta Object Tree (AOT)&lt;br /&gt;3. Expand classes node.&lt;br /&gt;4. Add the following class and method:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_owLhoazlDq8/SWceBxSGYnI/AAAAAAAAAA8/Fmf-zYNIJ8U/s1600-h/AXSampleMethod.JPG"&gt;&lt;img style="float:middle; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 141px;" src="http://3.bp.blogspot.com/_owLhoazlDq8/SWceBxSGYnI/AAAAAAAAAA8/Fmf-zYNIJ8U/s320/AXSampleMethod.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5289229303127892594" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;5. Test this method by executing it as a Job.&lt;br /&gt;(AOT-&gt; Jobs -&gt;Create a simple job -&gt; add the above code with an Info statement.)&lt;br /&gt;&lt;br /&gt;Once the above steps are executed successfully, the following are the steps for invoking this AX method in .NET.&lt;br /&gt;1. Open a new Console application using Visual Studio 2008&lt;br /&gt;2. Add the following Reference to the Project:&lt;br /&gt;Microsoft.Dynamics.BusinessConnectorNet&lt;br /&gt;This dll is present in:&lt;br /&gt; C:\Program Files\Microsoft Dynamics AX\40\Client\Bin&lt;br /&gt;3. Naviate to Program.cs file and add the following namespace for reference:&lt;br /&gt;using Microsoft.Dynamics.BusinessConnectorNet;&lt;br /&gt;4. Add the following code in main() to invoke the AX method:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                Axapta ax = new Axapta();&lt;br /&gt;                ax.Logon(null, null, null, null);&lt;br /&gt;                string strName = "  Microsoft Dynamics AX ";&lt;br /&gt;                AxaptaObject axObject;&lt;br /&gt;                axObject = ax.CreateAxaptaObject("NetConnector");&lt;br /&gt;                string resonseFromAxapta = (string)axObject.Call("SampleMethod", strName);&lt;br /&gt;                Console.WriteLine(resonseFromAxapta);&lt;br /&gt;                Console.ReadLine();&lt;br /&gt;                ax.Logoff();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(ex.Message);&lt;br /&gt;            }&lt;br /&gt;        }&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;5. Compile and Run the Application.&lt;br /&gt;Thats all about it! You now should see the data coming from Axapta in .NET.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-7679112788065473959?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/7679112788065473959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=7679112788065473959&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/7679112788065473959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/7679112788065473959'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2008/09/how-to-connect-to-ax-40-from-net.html' title='HOW TO: Connect to AX 4.0 from a .NET Application using Business connector'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_owLhoazlDq8/SRFtcc9RRtI/AAAAAAAAAAM/TtKCya2KYxU/s72-c/configtool.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-950543597769900297</id><published>2008-09-06T06:33:00.001-07:00</published><updated>2008-09-12T07:43:01.147-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows app'/><category scheme='http://www.blogger.com/atom/ns#' term='CSV Files'/><title type='text'>HOW TO: Create a CSV File using System.IO classes</title><content type='html'>CSV (Comma Separated Values) file is a text based file in which data are separated by comma. It can be opened by excel so you can use excel functionality. Each row of data including the title is in separate line. Each row has data separated by comma.&lt;br /&gt;&lt;br /&gt;If its an ASP.NET application, a CSV file can be easily created by setting the&lt;br /&gt;  HttpContext.Current.Response.ContentType = "text/csv";&lt;br /&gt;&lt;br /&gt;For other Windows applications or a Windows based service, the above method cannot be used. The other possible way is to use the Interop Excel object to create. However, this may require an extra dll to be added to your app. As this is an Interop dll, its not managed and maintaining this dll may become difficult in future.&lt;br /&gt;&lt;br /&gt;The following method gives an easier way of handling this - using the classes in System.IO namespace. The below is a code extract that shows how this can be done. We have used a simple example of getting a list of employees &lt;br /&gt;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;        private string[] empDetailsHeader = {&lt;br /&gt;   "Employee ID",&lt;br /&gt;   "Name",&lt;br /&gt;                        "Salary"&lt;br /&gt;   };&lt;br /&gt;        private const string separator = ",";&lt;br /&gt;&lt;br /&gt;        private void CreateCSVFile(string filePath){&lt;br /&gt;           try {&lt;br /&gt;                StringBuilder csvString = new StringBuilder();&lt;br /&gt;&lt;br /&gt;                List&lt;EmpDetails&gt; empList = new List&lt;EmpDetails&gt;();&lt;br /&gt;                //Writing the Header &lt;br /&gt;                &lt;br /&gt;                for (int i = 0; i &lt; empDetailsHeader.Count&lt;string&gt;(); i++){&lt;br /&gt;                    csvString.Append(empDetailsHeader[i]);&lt;br /&gt;                    csvString.Append(separator);&lt;br /&gt;                }&lt;br /&gt;                //Get the list containing the Employee details               &lt;br /&gt;                empList = GetEmployeeList();&lt;br /&gt;&lt;br /&gt;                csvString.AppendLine();&lt;br /&gt;                foreach (Employee employee in EmpDetails){&lt;br /&gt;                    csvString.Append(employee.ID.ToString());&lt;br /&gt;                    csvString.Append(separator);&lt;br /&gt;                    csvString.Append(employee.Name.ToString());&lt;br /&gt;                    csvString.Append(separator);&lt;br /&gt;                    csvString.Append(employee.Salary.ToString());&lt;br /&gt;                    csvString.Append(separator);&lt;br /&gt;                    //Next Line&lt;br /&gt;                    csvString.AppendLine();&lt;br /&gt;                }&lt;br /&gt;                //save the file&lt;br /&gt;                SaveFile(filePath, csvString);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;&lt;br /&gt;            private void SaveFile(string filePath, StringBuilder stringBuidler) {&lt;br /&gt;            if (File.Exists(filePath)){&lt;br /&gt;                File.Delete(filePath);&lt;br /&gt;              }else{&lt;br /&gt;                StreamWriter streamWriter = new StreamWriter(filePath);&lt;br /&gt;                streamWriter.Write(stringBuidler.ToString());&lt;br /&gt;                streamWriter.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;Now how do we take care if there is a comma in the data that we need to get into the CSV? Any comma in data is taken as a delimiter for taking the data to the next column. As a work around for this - to still maintain the same data, we can wrap the text using double quotes. &lt;br /&gt;&lt;br /&gt;For example, suppose the Salary column in the above data has a value 40,000. Some developers use the method of replacing this comma with space. By doing this we sometimes lose the authenticity of data.&lt;br /&gt;To make sure that we still maintain the correct data, we need to wrap the string with double quotes.&lt;br /&gt;&lt;br /&gt;char doubleQuote = '"';&lt;br /&gt;if(employee.Salary.ToString().Contains(",")) {&lt;br /&gt; csvString.Append(doubleQuote);&lt;br /&gt; csvString.Append(employee.Salary.ToString());&lt;br /&gt; csvString.Append(doubleQuote);&lt;br /&gt;}&lt;br /&gt;This will ensure that we have correct data in the CSV File that is created.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-950543597769900297?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/950543597769900297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=950543597769900297&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/950543597769900297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/950543597769900297'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2008/09/how-to-create-csv-file-using-systemio.html' title='HOW TO: Create a CSV File using System.IO classes'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-115814546254980247</id><published>2006-09-13T03:57:00.000-07:00</published><updated>2006-09-20T07:23:08.056-07:00</updated><title type='text'>ASP.NET 2.0 - A Preview of Web LINQ - BLINQ - Part II</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;a href="http://lakshmik.blogspot.com/2006/09/aspnet-20-preview-of-web-linq-blinq.html"&gt;Part I&lt;/a&gt; of this article discussed on the basics of &lt;strong&gt;LINQ&lt;/strong&gt;, and what &lt;strong&gt;DLINQ&lt;/strong&gt; and &lt;strong&gt;XLINQ&lt;/strong&gt; are.&lt;br /&gt;The following is a step by step procedure in using &lt;strong&gt;BLINQ&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;1. Download the MSI from:&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.asp.net/sandbox/app_blinq.aspx?tabid=62"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;a href="http://www.asp.net/sandbox/app_blinq.aspx?tabid=622"&gt;http://www.asp.net/sandbox/app_blinq.aspx?tabid=62&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;2&lt;/a&gt;.&lt;br /&gt;For using BLINQ, May 2006 CTP of LINQ must be installed in your machine.&lt;br /&gt;Refer &lt;a href="http://lakshmik.blogspot.com/2006/09/aspnet-20-preview-of-web-linq-blinq.html"&gt;Part I &lt;/a&gt;of the article for this.&lt;br /&gt;3. Install the MSI in your system. By default, BLINQ gets installed in &lt;strong&gt;C:\Program Files\Microsoft ASP.NET\BLINQ&lt;/strong&gt;.&lt;br /&gt;4. Open Visual Studio 2005. On the &lt;strong&gt;File&lt;/strong&gt; Menu, point to &lt;strong&gt;New&lt;/strong&gt; and then click &lt;strong&gt;Web Site&lt;/strong&gt;.&lt;br /&gt;5. Under Visual Studio installed templates, select &lt;strong&gt;ASP.NET Web Site&lt;/strong&gt;.&lt;br /&gt;6. In the Location drop down list, select &lt;strong&gt;File System&lt;/strong&gt; and give the path as&lt;strong&gt; C:\BLINQDemo&lt;/strong&gt; and then click &lt;strong&gt;OK&lt;/strong&gt;. This creates a new Web Applcation.&lt;br /&gt;7. Now click &lt;strong&gt;Start&lt;/strong&gt;, and then click &lt;strong&gt;Run&lt;/strong&gt;. Type &lt;strong&gt;cmd&lt;/strong&gt; in the &lt;strong&gt;Open&lt;/strong&gt; box and then click &lt;strong&gt;OK&lt;/strong&gt;.&lt;br /&gt;8. In the command prompt type &lt;strong&gt;cd "\Program Files\Microsoft ASP.NET\Blinq"&lt;/strong&gt; .&lt;br /&gt;9. Now run the BLinq tool on the created Web Site by typing the following command, replacing Servername,UserName and Password accordingly. Also copy the same&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;to a single line before running the command. I have split it here for posting&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;purposes:&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;"&gt;Blinq /t:c:\BLINQDemo /database:Northwind /vDir:BLINQDemo&lt;br /&gt;/server:ServerName /user:UserName /password:Password&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/command.jpg"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/command.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;br /&gt;10. You will be prompted if your web site can be over written. Type &lt;strong&gt;Y&lt;/strong&gt; and then press enter.&lt;br /&gt;11. After successful creation, you will get a message &lt;strong&gt;WebApp created at C:\Blinqdemo&lt;/strong&gt;.And the web site opens up at &lt;strong&gt;http://localhost/blinqdemo/categories.aspx&lt;/strong&gt;, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/entireSite.0.jpg"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/entireSite.0.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;br /&gt;You will also be able to perform all Insert,Update,Delete, View (CRUD) options on the entire Database. The image below shows the Update,Delete and View options in Categories.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/categories.0.jpg"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/categories.0.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;br /&gt;BLINQ is definitely an exciting tool for every developer. Let us wait for the next release of this tool, integrated with Visual Studio.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-115814546254980247?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/115814546254980247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=115814546254980247&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115814546254980247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115814546254980247'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/09/aspnet-20-preview-of-web-linq-blinq_13.html' title='ASP.NET 2.0 - A Preview of Web LINQ - BLINQ - Part II'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-115814208223640612</id><published>2006-09-13T02:19:00.000-07:00</published><updated>2006-09-13T03:56:25.233-07:00</updated><title type='text'>ASP.NET 2.0 - A Preview of Web LINQ - BLINQ - Part I</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;LINQ&lt;/strong&gt; has been the recent buzz word as its a part of the C# 3.0 family. In this article let us take a quick look at what &lt;strong&gt;LINQ&lt;/strong&gt;, &lt;strong&gt;DLINQ&lt;/strong&gt; and &lt;strong&gt;XLINQ&lt;/strong&gt; are all about and what &lt;strong&gt;BINQ - Web LINQ&lt;/strong&gt; offers us. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;LINQ&lt;/strong&gt; - &lt;strong&gt;Language Integrated Query&lt;/strong&gt; is a technology that gives us the flexibility of performing query language operations in .NET. Formerly introduced as ObjectSpaces, LINQ is now available as a Community Technology Preview in &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/data/ref/linq"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;http://msdn.microsoft.com/data/ref/linq&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;The first step is to download the May 2006 CTP from the above link and install the same in your system. The CTP requires that Visual Studio 2005 is installed in your system. On installing the same, you will find a lot of samples and documents that are given as a part of the CTP.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Trebuchet MS;color:#000099;"&gt;&lt;br /&gt;LINQ provies a lot of features to improve the developer productivity by minimizing a lot of data access code.&lt;/span&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Following is a sample of a query operation over an array. Such a typer of operation is not possible now in C# 2.0 and you need to loop through all elements in the array to find out the words with length 5.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;using System;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;using System.Query;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;using System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;class app {&lt;br /&gt;static void Main() {&lt;br /&gt;string[] names = { "Burke", "Connor", "Frank",&lt;br /&gt;"Everett", "Albert", "George",&lt;br /&gt;"Harris", "David" };&lt;br /&gt;&lt;br /&gt;IEnumerable&lt;string&gt; expr = from s in names&lt;br /&gt;where s.Length == 5&lt;br /&gt;orderby s&lt;br /&gt;select s.ToUpper();&lt;br /&gt;&lt;br /&gt;foreach (string item in expr)&lt;br /&gt;Console.WriteLine(item);&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;DLINQ is LINQ operated on relational data, such as data from SQL Server. The following is a sample on how&lt;br /&gt;you can query the Products information in Northwind database. The metadata information of the tables&lt;br /&gt;present in the Northwind database is generated using a tool called sqlmetal by pointing a particular database&lt;br /&gt;to it. In the below snippet, NorthwindDataContext class contains all metadata about the entire Northwind&lt;br /&gt;database.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;NorthwindDataContext db = new NorthwindDataContext();&lt;br /&gt;&lt;br /&gt;DataList1.DataSource = from p in db.Products&lt;br /&gt;where p.UnitPrice &gt; 20&lt;br /&gt;orderby p.ProductName&lt;br /&gt;select p;&lt;br /&gt;DataList1.DataBind();&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;XLINQ is LINQ operating on XML data. Consider the following XML block:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;&amp;lt;contacts&amp;gt;&lt;br /&gt;&amp;lt;contact&amp;gt;&lt;br /&gt;&amp;lt;name&amp;gt;Great Lakes Food&amp;lt;/name&amp;gt;&lt;br /&gt;&amp;lt;phone&amp;gt;(503) 555-7123&amp;lt;/phone&amp;gt;&lt;br /&gt;&amp;lt;/contact&amp;gt;&lt;br /&gt;…&lt;br /&gt;&amp;lt;/contacts&amp;gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Using today's C# 2.0, we need loop through each of the customer records in the collection to build an XML as&lt;br /&gt;above. XLINQ significantly improves this process. A sample code using XLINQ to build a simple XML is given below:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;XElement contacts = new XElement("contacts",&lt;br /&gt;from c in customers&lt;br /&gt;where c.Country == "USA"&lt;br /&gt;select new XElement("contact",&lt;br /&gt;new XElement("name", c.CompanyName),&lt;br /&gt;new XElement("phone", c.Phone)&lt;br /&gt;)&lt;br /&gt;);&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;BLINQ is currently a tool, available for download at :&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.asp.net/sandbox/app_blinq.aspx?tabid=62"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;http://www.asp.net/sandbox/app_blinq.aspx?tabid=62&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;In the next article we will discuss on how to start using BLINQ.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-115814208223640612?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/115814208223640612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=115814208223640612&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115814208223640612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115814208223640612'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/09/aspnet-20-preview-of-web-linq-blinq.html' title='ASP.NET 2.0 - A Preview of Web LINQ - BLINQ - Part I'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-115752239274830512</id><published>2006-09-05T22:39:00.000-07:00</published><updated>2006-11-01T05:05:29.950-08:00</updated><title type='text'>ASP.NET - Maintaining Versions in Web Setup projects</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;During deployment of projects, many times we come across the situation to reinstall the same application with some changes to the code. Usually when we have an MSI build, the build often prompts us to uninstall the older version and reinstall the latest version.&lt;br /&gt;&lt;br /&gt;In this article we will discuss on how to install different versions of the same application and not force overwriting the application. The steps for creating an MSI installer for ASP.NET 2.0 projects is explained in &lt;/span&gt;&lt;a href="http://lakshmik.blogspot.com/2006/06/aspnet-20-deployment-installer-for.html"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;this article&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;.&lt;br /&gt;&lt;br /&gt;Everytime a new version of a product is installed the reason why the MSI prompts to uninstall the existing application and install a new version is due to the same &lt;strong&gt;ProductCode&lt;/strong&gt; Guid that is present in both the older version and the newer version of the product.&lt;br /&gt;&lt;br /&gt;To install different versions of the same application, follow these steps:&lt;br /&gt;1. Add the setup project to your application and add the necessary primary outputs as described in &lt;/span&gt;&lt;a href="http://lakshmik.blogspot.com/2006/06/aspnet-20-deployment-installer-for.html"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;this article&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;. Name this project as MySetupProject.&lt;br /&gt;&lt;br /&gt;2. Select MySetupProject in &lt;strong&gt;Solution Explorer&lt;/strong&gt; and then press &lt;strong&gt;F4&lt;/strong&gt; key. This will open the &lt;strong&gt;Properties&lt;/strong&gt; window.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/VersionProperty.jpg"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/VersionProperty.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;br /&gt;3. Note the &lt;strong&gt;Version&lt;/strong&gt; property in the left column. Everytime a newer version of the application needs to be installed, increment the version number, say from &lt;strong&gt;1.0.0&lt;/strong&gt; to &lt;strong&gt;1.0.1 &lt;/strong&gt;and so on.When you change this number and press enter, you will get the following prompt:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/DeploymentVersion.jpg"&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;img style="MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/DeploymentVersion.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;br /&gt;4. Click Yes on the prompt. You will notice that ProductCode property value (a GUID) is changed once you change the version number.&lt;br /&gt;5. Now notice the &lt;strong&gt;RemovePreviousVersions&lt;/strong&gt; property. This property is for specifying whether to over write the different versions or to have the different versions separately.&lt;br /&gt;Making the &lt;strong&gt;RemovePreviousVersions&lt;/strong&gt; to &lt;strong&gt;true&lt;/strong&gt; means that every new version of your product will be over written.&lt;br /&gt;Making this property to &lt;strong&gt;False&lt;/strong&gt; gives you the flexibility to have both your older version and the newer version separately installed.&lt;br /&gt;&lt;br /&gt;Thus by incrementing the &lt;strong&gt;Version&lt;/strong&gt; and making &lt;strong&gt;RemovePreviousVersions&lt;/strong&gt; to False you can have different versions of the same product running on your machine.&lt;br /&gt;&lt;br /&gt;Now with this setup, we must also ensure that only a particular version that we need is used after deployment. The next article discusses on this topic of using a preferred version of your application after deployment. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-115752239274830512?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/115752239274830512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=115752239274830512&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115752239274830512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115752239274830512'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/09/aspnet-maintaining-versions-in-web.html' title='ASP.NET - Maintaining Versions in Web Setup projects'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-115096254539511853</id><published>2006-06-21T23:37:00.000-07:00</published><updated>2006-11-14T06:33:45.693-08:00</updated><title type='text'>ASP.NET 2.0 Deployment : Installer for updating Web.Config settings during Setup - Part II</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;In &lt;a href="http://lakshmik.blogspot.com/2006/05/aspnet-20-deployment-installer-for.html"&gt;Part I &lt;/a&gt;of the article we saw how Visual Studio 2005 Web Deployment Projects help in deployment of ASP.NET 2.0 applications. Let us now look at how we can make use of this add-on in building an MSI that also sets the configuration settings.&lt;br /&gt;&lt;br /&gt;The first step is to add an installer class in your web project. This installer class will be used in setting the configuration settings in web.config. The following steps will discuss on adding the installer class:&lt;br /&gt;&lt;br /&gt;1. Right click on your web project, and then click &lt;strong&gt;Add New Item&lt;/strong&gt;.&lt;br /&gt;2. Under &lt;strong&gt;Templates&lt;/strong&gt;, click Class, and then give the name of the class as InstallerClass.cs.&lt;br /&gt;3. This will get added in the &lt;strong&gt;App_Code&lt;/strong&gt; folder in your web application.&lt;br /&gt;4. Right click on the Web Project, and then click &lt;strong&gt;Add Reference&lt;/strong&gt;. Add the following references to the Web project:&lt;br /&gt;System.Configuration.Install&lt;br /&gt;System.Configuration&lt;br /&gt;System.Windows.Forms&lt;br /&gt;5. Open InstallerClass.cs, and then replace it with the following code:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Configuration.Install;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Xml;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Summary description for InstallerClass&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;[RunInstaller(true)]&lt;br /&gt;public class InstallerClass : System.Configuration.Install.Installer&lt;br /&gt;{&lt;br /&gt;private System.ComponentModel.Container components = null;&lt;br /&gt;public InstallerClass()&lt;br /&gt;{&lt;br /&gt;components = new System.ComponentModel.Container();&lt;br /&gt;}&lt;br /&gt;protected override void OnBeforeInstall(IDictionary stateSaver)&lt;br /&gt;{&lt;br /&gt;string server = this.Context.Parameters["DATASOURCE"];&lt;br /&gt;string userId = this.Context.Parameters["USERID"];&lt;br /&gt;string password = this.Context.Parameters["PASSWORD"];&lt;br /&gt;string newConnectionString = "User Id=" + userId + ";Password= " + password + ";Data Source =" + server + ";";&lt;br /&gt;string xmlConfigFile = "";&lt;br /&gt;xmlConfigFile = Context.Parameters["INSTALLDIR"] + "web.config";&lt;br /&gt;UpdateConfigFile(xmlConfigFile, newConnectionString, "connectionString");&lt;br /&gt;}&lt;br /&gt;public void UpdateConfigFile(string filepath, string newValue, string keyName)&lt;br /&gt;{&lt;br /&gt;XmlReaderSettings xmlReaderSettings = null;&lt;br /&gt;XmlDocument doc = null;&lt;br /&gt;XmlReader xmlReader = null;&lt;br /&gt;XmlWriterSettings xmlWriterSettings = null;&lt;br /&gt;XmlWriter writer = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;xmlReaderSettings = new XmlReaderSettings();&lt;br /&gt;doc = new XmlDocument();&lt;br /&gt;xmlReader = XmlReader.Create(filepath, xmlReaderSettings);&lt;br /&gt;doc.Load(xmlReader);&lt;br /&gt;xmlReaderSettings.CloseInput = true;&lt;br /&gt;foreach (XmlNode node in doc.DocumentElement.ChildNodes)&lt;br /&gt;{&lt;br /&gt;if (node.Name == "connectionStrings")&lt;br /&gt;foreach (XmlNode childNode in node.ChildNodes)&lt;br /&gt;{&lt;br /&gt;if (childNode.Name == "add" &amp;&amp;amp; childNode.Attributes["connectionString"] != null &amp;&amp;amp; childNode.Attributes["name"].Value == keyName)&lt;br /&gt;{&lt;br /&gt;string connStr = childNode.Attributes["connectionString"].Value.ToString();&lt;br /&gt;string newConnStr = newValue;&lt;br /&gt;childNode.Attributes["connectionString"].Value = newConnStr;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;xmlReader.Close();&lt;br /&gt;xmlWriterSettings = new XmlWriterSettings();&lt;br /&gt;xmlWriterSettings.Indent = true;&lt;br /&gt;xmlWriterSettings.CloseOutput = true;&lt;br /&gt;writer = XmlWriter.Create(filepath, xmlWriterSettings);&lt;br /&gt;doc.Save(writer);&lt;br /&gt;}&lt;br /&gt;catch (Exception)&lt;br /&gt;{&lt;br /&gt;//Handle exeptions&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;writer.Close();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;6. Save the file and build your web project.&lt;br /&gt;&lt;br /&gt;In &lt;a href="http://lakshmik.blogspot.com/2006/05/aspnet-20-deployment-installer-for.html"&gt;Part I&lt;/a&gt; of the article we discussed on how to add a Web deployment. Make sure the Web Deployment Project is added to the Web project and the settings are done as detailed in Part I of this article. Rebuild this Web Deployment project also.&lt;br /&gt;&lt;br /&gt;The next step is to build an MSI. The following steps explain the same:&lt;br /&gt;&lt;br /&gt;1. Right click on the solution node in Solution Explorer, point to &lt;strong&gt;Add&lt;/strong&gt;, and then click &lt;strong&gt;New Project&lt;/strong&gt;.&lt;br /&gt;2. Select&lt;strong&gt; Setup and Deployment&lt;/strong&gt; under&lt;strong&gt; Other Project Types&lt;/strong&gt; from the &lt;strong&gt;Project Types&lt;/strong&gt; box.&lt;br /&gt;3. Select &lt;strong&gt;Web Setup Project&lt;/strong&gt; under &lt;strong&gt;Templates&lt;/strong&gt;, and then give a name &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt;.&lt;br /&gt;4. Right click &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt; on Solution Explorer, point to &lt;strong&gt;Add&lt;/strong&gt;, and then click &lt;strong&gt;Project Output&lt;/strong&gt;.&lt;br /&gt;5. From the &lt;strong&gt;Project&lt;/strong&gt; dropdown, choose &lt;mynewwebsite_deploy&gt;(i.e. the Web Deployment project that you have added and compiled). You will find that &lt;strong&gt;Precompiled Web Outputs from &lt;mynewwebsite_deploy&gt;(Active)&lt;/strong&gt; is added to your Setup project.&lt;br /&gt;6. Right click &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt; on Solution Explorer, point to &lt;strong&gt;Add&lt;/strong&gt;, and then click &lt;strong&gt;Assembly&lt;/strong&gt;.&lt;br /&gt;7. From the &lt;strong&gt;Browse&lt;/strong&gt; tab, browse to the folder where your Web Deployment Project is present. Under the &lt;strong&gt;MyNewWebSite_deploy &lt;mynewwebsite_deploy&gt;&lt;mynewwebsite_deploy&gt;-&gt; Debug -&gt; Bin&lt;/strong&gt; path you will find the single assembly of the Web Project that was created, named &lt;strong&gt;MyNewWebSiteAssembly&lt;/strong&gt;&lt;br /&gt;(refer &lt;strong&gt;Point 5&lt;/strong&gt; in &lt;strong&gt;&lt;a href="http://lakshmik.blogspot.com/2006/05/aspnet-20-deployment-installer-for.html"&gt;Part I&lt;/a&gt;&lt;/strong&gt; of the article).&lt;br /&gt;8. Right click &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt; on &lt;strong&gt;Solution Explorer&lt;/strong&gt;, point to &lt;strong&gt;View&lt;/strong&gt;, and then click &lt;strong&gt;User Interface&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;9. Under the &lt;strong&gt;Install&lt;/strong&gt; node, right click on &lt;strong&gt;Start &lt;/strong&gt;and then click &lt;strong&gt;Add Dialog&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;10. From the Add Dialog pop up choose &lt;strong&gt;Textboxes (A)&lt;/strong&gt; and then click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;11. Right click &lt;strong&gt;Textboxes (A)&lt;/strong&gt; node and then click &lt;strong&gt;Properties Window&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;12. In the &lt;strong&gt;Properties window&lt;/strong&gt;, set the following properties:&lt;br /&gt;&lt;strong&gt;BannerText &lt;/strong&gt;- Configuration Settings&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;BodyText&lt;/strong&gt;- Please provide values for Configuration Settings&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Edit1Label&lt;/strong&gt;-DataSource:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Edit1Property&lt;/strong&gt;- DATASOURCE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Edit2Label&lt;/strong&gt;-UserId:&lt;br /&gt;&lt;strong&gt;Edit2Property&lt;/strong&gt;- USERID&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Edit3Label&lt;/strong&gt;-Password:&lt;br /&gt;&lt;strong&gt;Edit3Property&lt;/strong&gt;- PASSWORD&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;Edit4Visible&lt;/strong&gt;-False&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;13. After setting the above properties, close the Properties window.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;14. Right click &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt; on Solution Explorer, point to &lt;strong&gt;View&lt;/strong&gt;, and then click &lt;strong&gt;Custom Actions&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;15. On the left pane, right click &lt;strong&gt;Install&lt;/strong&gt; node under &lt;strong&gt;Custom Actions&lt;/strong&gt;, and then click &lt;strong&gt;Add Custom Action&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;16. In the &lt;strong&gt;Look in &lt;/strong&gt;dropdown list in &lt;strong&gt;Select Item in Project dialog&lt;/strong&gt;, select &lt;strong&gt;Web Application Folder&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;17. Click the &lt;strong&gt;Add File&lt;/strong&gt; button and then choose the single assembly dll that is present under the &lt;mynewwebsite_deploy&gt;&lt;strong&gt;MyNewWebSite_deploy -&gt; Debug -&gt; Bin -&gt; MyNewWebSiteAssembly.dll&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Note :&lt;/strong&gt; If you have not set any path when adding, it would be present in C:\Documents and Settings\ My Documents\Visual Studio 2005\Projects\ GridViewWeb\ MyNewWebSite_deploy\ Debug\bin\ MyNewWebSiteAssembly.dll.&lt;br /&gt;&lt;br /&gt;18. Right click&lt;strong&gt; MyNewWebSiteAssembly.dll&lt;/strong&gt; on the left pane, and then click &lt;strong&gt;Properties Window&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;19. In the Properties Window, set the &lt;strong&gt;CustomActionData&lt;/strong&gt; property to the following:&lt;br /&gt;/datasource=[DATASOURCE] / userid=[USERID] /password=[PASSWORD] /INSTALLDIR="[TARGETDIR]\"&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;These are precisely the properties we use in the InstallerClass.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;20. Right click &lt;strong&gt;MyNewWebSiteSetup&lt;/strong&gt; on Solution Explorer, and then click &lt;strong&gt;Build&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;21. You can test the installation of MSI using the &lt;strong&gt;Install&lt;/strong&gt; option when you right click MyNewWebSiteSetup on Solution Explorer.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;You will find that you can set the connection string properties at runtime during installation of your Web Application.&lt;br /&gt;&lt;br /&gt;22. Set your project in &lt;strong&gt;Release&lt;/strong&gt; mode, and then take a build again to take the final installable.&lt;br /&gt;&lt;br /&gt;While picking up the single assembly dll was straight forward in ASP.NET 1.1, in ASP.NET 2.0, this has been made possible with the Visual Studio Web Deployment Project Add on. This makes adding the Custom Actions possible.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-115096254539511853?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/115096254539511853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=115096254539511853&amp;isPopup=true' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115096254539511853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/115096254539511853'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/06/aspnet-20-deployment-installer-for.html' title='ASP.NET 2.0 Deployment : Installer for updating Web.Config settings during Setup - Part II'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114968087696993754</id><published>2006-06-07T04:12:00.000-07:00</published><updated>2006-07-17T05:35:17.000-07:00</updated><title type='text'>ASP.NET 2.0 - Custom Paging and Custom Sorting for GridViews</title><content type='html'>&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Paging and sorting GridViews are the most sought after functionalities in most of the Web applications.When it comes to performance, for datacentric applications its very important to implement the custom paging/sorting mechanism instead of the&lt;br /&gt;default paging/sorting for gridviews. This is because the page becomes heavily loaded when thousands of records are fetched at a strech from the&lt;br /&gt;database.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;To overcome this, we must implement a "Custom paging" mechanism which brings record only "on-demand". This article discusses how this can be&lt;br /&gt;implemented in ASP.NET 2.0 with zero lines of code in presentation layer.&lt;br /&gt;&lt;br /&gt;1. The first step is to write a stored proc, GetSortedItems that accepts these parameters and returns a resultset.&lt;br /&gt;&lt;br /&gt;a. SortExpression&lt;br /&gt;b. StartRow&lt;br /&gt;c. EndRow&lt;br /&gt;&lt;br /&gt;For Example, if the parameter values are ("ItemId desc", 5,10), which means the rows 5 to 10 have to be retrieved, with ItemId sorted in descending&lt;br /&gt;order.&lt;br /&gt;&lt;br /&gt;2. Another stored proc must be written, say GetItemsCount that returns the count of records that is returned from the resultset.&lt;br /&gt;&lt;br /&gt;3. Next step is to call the stored proc in the Data Access layer, and return a Collection object.&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;The following is an example of a DAL method using ODP.NET of Oracle:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;public QueryList GetSortedQueries(string sort, int startRowIndex, int maximumRows, int x, string y)&lt;br /&gt;{&lt;br /&gt;DataSet dsQueryList = null;&lt;br /&gt;OdpHelper adoHelper = new OdpHelper();&lt;br /&gt;QueryEntity queryEntity = null;&lt;br /&gt;QueryList queryList = null;&lt;br /&gt;string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;&lt;br /&gt;IDataParameter[] param = null;&lt;br /&gt;param = adoHelper.GetDataParameters(4);&lt;br /&gt;param[0] = adoHelper.GetRefCurParameter("p_cursor");&lt;br /&gt;param[0].Direction = ParameterDirection.Output;&lt;br /&gt;param[1] = adoHelper.GetParameter("P_SortExp",&lt;br /&gt;DbType.String,&lt;br /&gt;1000,&lt;br /&gt;ParameterDirection.Input&lt;br /&gt;);&lt;br /&gt;param[1].Value = sort;&lt;br /&gt;param[2] = adoHelper.GetParameter("BV_STARTROW",&lt;br /&gt;DbType.Int32,&lt;br /&gt;4,&lt;br /&gt;ParameterDirection.Input&lt;br /&gt;);&lt;br /&gt;param[2].Value = startRowIndex;&lt;br /&gt;param[3] = adoHelper.GetParameter("BV_ENDROW",DbType.Int32,4,ParameterDirection.Input);&lt;br /&gt;int lastRow = startRowIndex + maximumRows;&lt;br /&gt;param[3].Value = lastRow;&lt;br /&gt;dsQueryList = adoHelper.ExecuteDataset(connectionString,"TestCustomPagingWithSorting",param);&lt;br /&gt;queryList = new QueryList();&lt;br /&gt;//loops through the dataset rows to load displaycontrols retrieved into the list&lt;br /&gt;if (dsQueryList.Tables.Count &gt; 0)&lt;br /&gt;{&lt;br /&gt;if (dsQueryList.Tables[0].Rows.Count &gt; 0)&lt;br /&gt;{&lt;br /&gt;foreach (DataRow drQueryEntity in dsQueryList.Tables[0].Rows)&lt;br /&gt;{&lt;br /&gt;queryEntity = new QueryEntity();&lt;br /&gt;if (drQueryEntity["queryid"] != DBNull.Value)&lt;br /&gt;{&lt;br /&gt;queryEntity.QueryId = Convert.ToInt32(drQueryEntity["queryid"].ToString());&lt;br /&gt;}&lt;br /&gt;if (drQueryEntity["querytypeid"] != DBNull.Value)&lt;br /&gt;{&lt;br /&gt;queryEntity.QueryTypeId = Convert.ToInt32(drQueryEntity["querytypeid"].ToString());&lt;br /&gt;}&lt;br /&gt;queryList.Add(queryEntity);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return queryList;&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;4. In the Presentation layer, all we have to do is to add an ObjectDataSource control and set the following properties: &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color:#000099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;SelectMethod&lt;/strong&gt; property to the GetSortedQueryList method - either from Data Access Layer or Business Facade &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#000099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;TypeName&lt;/strong&gt; property to the Data Access Layer or Business Facade class that has the specific method. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#000099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;SortParameterName&lt;/strong&gt; property to the parameter name in which the Sort expression is passed. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color:#000099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;SelectCountMethod&lt;/strong&gt; is the method in the Data Access Layer or Business Facade class that returns the count of records. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;The &lt;&lt;strong&gt;SelectParameters&lt;/strong&gt;&gt; are the individual parameters that are present passed to the &lt;strong&gt;SelectMethod&lt;/strong&gt; and &lt;strong&gt;SelectCountMethod&lt;/strong&gt;.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:trebuchet ms;color:#333399;"&gt;If the GridView has to be bound on triggering of an event, just do not specify the DataSourceID="ObjectDataSource1" in GridView, and add these&lt;br /&gt;two lines of code in the event.&lt;br /&gt;GridView1.DataSourceID = "ObjectDataSource1";&lt;br /&gt;GridView1.DataBind();&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="color:#000099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;Note:&lt;/strong&gt; The method signature of &lt;strong&gt;SelectCountMethod&lt;/strong&gt; must necessarily contain all parameters of &lt;strong&gt;SelectMethod&lt;/strong&gt;, even though these may not be used.&lt;br /&gt;&lt;br /&gt;Ex:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;&amp;lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSortedQueryList"&lt;br /&gt;SortParameterName="sort" TypeName="CustomPagingService.CustomPagingService" SelectCountMethod="GetQueryListCount"&lt;br /&gt;EnablePaging="True" &gt;&lt;br /&gt;&amp;lt;SelectParameters&gt;&lt;br /&gt;&amp;lt;asp:Parameter DefaultValue="Asc" Name="sort" Type="String" /&gt;&lt;br /&gt;&amp;lt;asp:Parameter DefaultValue="1" Name="startRowIndex" Type="Int32" /&gt;&lt;br /&gt;&amp;lt;asp:Parameter DefaultValue="10" Name="maximumRows" Type="Int32" /&gt;&lt;br /&gt;&amp;lt;asp:Parameter DefaultValue="10" Name="x" Type="Int32" /&gt;&lt;br /&gt;&amp;lt;asp:Parameter DefaultValue="" Name="y" Type="String" /&gt;&lt;br /&gt;&amp;lt;/SelectParameters&gt;&lt;br /&gt;&amp;lt;/asp:ObjectDataSource&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;strong&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&amp;lt;asp:GridView ID="GridView2" DataKeyNames="QueryId" runat="server" AllowPaging="True"&lt;br /&gt;AllowSorting="true" AutoGenerateColumns="false"&lt;br /&gt;PageSize="5"&gt;&lt;br /&gt;&amp;lt;Columns&gt;&lt;br /&gt;&amp;lt;asp:BoundField DataField="QueryId" ReadOnly="true" HeaderText="QueryId" SortExpression="QueryId" /&gt;&lt;br /&gt;&amp;lt;asp:BoundField DataField="QueryTypeId" ReadOnly="true" HeaderText="QueryTypeId"&lt;br /&gt;SortExpression="QueryTypeId" /&gt;&lt;br /&gt;&amp;lt;/Columns&gt;&lt;br /&gt;&amp;lt;PagerSettings FirstPageText="First" LastPageText="Last" Mode="NumericFirstLast" /&gt;&lt;br /&gt;&amp;lt;/asp:GridView&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;Thats it. Just compile and run your page. You will find that by just setting properties with no line of code in the presentation layer, Custom paging and sorting functionalites are achieved.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114968087696993754?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114968087696993754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114968087696993754&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114968087696993754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114968087696993754'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/06/aspnet-20-custom-paging-and-custom.html' title='ASP.NET 2.0 - Custom Paging and Custom Sorting for GridViews'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114769959066683099</id><published>2006-05-15T06:23:00.000-07:00</published><updated>2007-02-11T09:02:44.236-08:00</updated><title type='text'>ASP.NET 2.0 Deployment : Installer for updating Web.Config settings during Setup - Part I</title><content type='html'>Many of us are aware of ASP.NET deployment using Web Setup Projects. There are many articles that describe this.&lt;br /&gt;Web.config forms a crucial part in any web application. When a Web Application is deployed in a client's place it becomes a brilliant idea to provide a UI for updating the Web.config settings.&lt;br /&gt;&lt;br /&gt;In ASP.NET 1.1 this was quite straight forward, where you can directly use the assembly of the Web project and create Custom Actions in Web Setup. However, in ASP.NET 2.0 this is quite tricky. This is because of the compilation model of ASP.NET 2.0. By default the compilation model does not give any single dll that can be added to the Custom Actions of Web Setup.&lt;br /&gt;&lt;br /&gt;For this reason, Microsoft has released a new Add-On called the Visual Studio 2005 Web Deployment Projects. Click &lt;a href="http://msdn.microsoft.com/library/en-us/dnaspp/html/web_deployment_projects.asp"&gt;here &lt;/a&gt;for more details and a free download.&lt;br /&gt;Let us check how this Add-on can be help in our deployment, in a step by step fashion.&lt;br /&gt;&lt;br /&gt;1. The First step is to install the Add-on from the link above.&lt;br /&gt;2. Once you install the Add-on, right click on your Web Project. You will notice a new menu called &lt;strong&gt;Add Web Deployment Project&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/webdev.0.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/webdev.0.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;3. On clicking this you will be prompted to give a name and location for this project. Give a proper name and location and click OK.The new Web Deployment gets added to your Solution.&lt;br /&gt;4. Right click the new project and then click Property Pages.&lt;br /&gt;5. In the&lt;strong&gt; Configuration Properties&lt;/strong&gt; treeview, click &lt;strong&gt;Output Assemblies&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/assembly.1.jpg"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/assembly.1.jpg" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;6. Select the &lt;strong&gt;Merge all outputs to a single assembly&lt;/strong&gt; option, and give an assembly name, say MyAssembly.&lt;br /&gt;7. Also check the &lt;strong&gt;Treat as library component&lt;/strong&gt; checkbox and then click OK.&lt;br /&gt;8. Build the Web Deployment project.&lt;br /&gt;9. Now browse to the location of the Web Deployment project you added from Windows Explorer.&lt;br /&gt;10. You will find that your asp.net pages along with Web.config are added to this folder. Also, there is a Debug\bin folder that contains the single assembly dll for your Web Application.&lt;br /&gt;&lt;br /&gt;This is similar to the ASP.NET 1.1 compilation model. This makes the deployment of our ASP.NET 2.0 easy.&lt;br /&gt;In Part II of this article, let us see how this can be integrated to update Web.Config during deployment.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114769959066683099?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114769959066683099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114769959066683099&amp;isPopup=true' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114769959066683099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114769959066683099'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/05/aspnet-20-deployment-installer-for.html' title='ASP.NET 2.0 Deployment : Installer for updating Web.Config settings during Setup - Part I'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114596888293586157</id><published>2006-04-25T05:32:00.000-07:00</published><updated>2006-05-16T22:55:34.603-07:00</updated><title type='text'>ASP.NET : Binding XML Data to TreeView with Checked state of Checkboxes</title><content type='html'>Often we come across data that is hierarchial in nature.&lt;br /&gt;&lt;br /&gt;Let us take a real world example of a profile page of a person that takes the interests of a person. The Interest categories are categorized in a hierarchial structure, with Categories such as Books, Entertainment, Sports, etc. There will be sub categories, for example, for Books category there might be sub categories as Religion, Literature, etc. and Region might have sub sub categories such as Christianity, Hinduism, etc.&lt;br /&gt;&lt;br /&gt;The best way such type of Hierarchial data can be shown is through a Treeview control. To bind the entire set of categories, sub categories, sub sub categories, the best way is to bind the TreeView with XML.&lt;br /&gt;&lt;br /&gt;In ASP.NET 2.0 we have an XmlDataSource control that serves exactly this purpose. The XMLDataSource can take up any static XML file that contains XML data.&lt;br /&gt;&lt;br /&gt;Ex:&lt;br /&gt;&amp;lt;asp:XmlDataSource ID="CategoriesXmlDataSource" runat="server" DataFile="MyXml.xml"&gt;&amp;lt;/asp:XmlDataSource&gt;&lt;br /&gt;&lt;br /&gt;The XmlDataSource also has a XPath property that is used to filter data in the xml.In case the data to be bound comes from database, we can use the Data property of XmlDataSource control to directly bind the xml string from database to the treeview. From the example we have taken on the Categories and Sub categories, we intend to show check boxes on the treeview, and also want the check boxes to be in checked state according to how the profile has been updated for the person. Let us now check on how we can achieve this.&lt;br /&gt;&lt;br /&gt;The first step is to write a proper query that gives an xml document as output. This Xml document must basically contain the entire hierarchial structure that must be displayed as a treeview.If SQL Server is your database, you can easily achieve this by using joins and using the "for xml auto" clause in your query.&lt;br /&gt;&lt;br /&gt;Now if you wish to bind the checked state of check boxes as well, using the data from database, you must also bring this checked state as another attribute of every node.&lt;br /&gt;&lt;br /&gt;Ex: The xml from database must be something like:&lt;br /&gt;&lt;br /&gt;&amp;lt;Categories&gt;&lt;br /&gt;&amp;lt;Category ID="1" Name="Books" checked="false"&gt;&lt;br /&gt;&amp;lt;SubCategory Id="2" Name="Religon" checked="false"&gt;&lt;br /&gt;&amp;lt;SubSubCategory Id="Hinduism" checked="true" /&gt;&lt;br /&gt;&amp;lt;SubSubCategory Id="Christianity" checked="false" /&gt;&lt;br /&gt;&amp;lt;SubSubCategory Id="Islam" checked="true" /&gt;&lt;br /&gt;&amp;lt;/SubCategory&gt;&lt;br /&gt;&amp;lt;/Category&gt;&lt;br /&gt;&amp;lt;/Categories&gt;&lt;br /&gt;&lt;br /&gt;The next step is to make this xml from database to be the datasource for XmlDatasource control. To do this, add this declaration in your aspx page:&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="/Categories/*"&gt;&amp;lt;/asp:XmlDataSource&gt;&lt;br /&gt;&lt;br /&gt;The XPath expression filtes out the top root node and displays the rest of the nodes.&lt;br /&gt;Now in the code behind page add this code in Page_load event:&lt;br /&gt;&lt;br /&gt;XmlDataSource1.Data = GetXmlData();&lt;br /&gt;&lt;br /&gt;The GetXmlData method retuns the entire xml structure as shown above from database.&lt;br /&gt;The final step is to bind the Treeview control with this XmlDataSource. This is done using the &amp;lt;DataBindings&gt; property of the ASP.NET Treeview.&lt;br /&gt;&lt;br /&gt;To the &lt;strong&gt;&amp;lt;DataBindings&gt;&lt;/strong&gt; of the Treeview we add the TreeNodeBinding, for each of the different levels in the TreeView.&lt;br /&gt;&lt;br /&gt;For this, add the following declaration in your aspx page:&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:TreeView runat="server" ID="tvwCategories" ExpandDepth=1 OnTreeNodeDataBound="tvwCategories_TreeNodeDataBound" ShowCheckBoxes="All" &gt;&lt;br /&gt;&amp;lt;DataBindings&gt;&lt;br /&gt;&amp;lt;asp:TreeNodeBinding DataMember="Country" SelectAction=None PopulateOnDemand=true TargetField="checked" ValueField="ID" extField="Name"&gt;&amp;lt;/asp:TreeNodeBinding&gt;&lt;br /&gt;&amp;lt;asp:TreeNodeBinding DataMember="Geography" PopulateOnDemand=true SelectAction=None TargetField="checked" ValueField="ID" TextField="Name"&gt;&amp;lt;/asp:TreeNodeBinding&gt;&lt;br /&gt;&amp;lt;asp:TreeNodeBinding DataMember="Region" TargetField="checked" SelectAction=None PopulateOnDemand=true ValueField="ID" TextField="Name"&gt;&amp;lt;/asp:TreeNodeBinding&gt;&lt;br /&gt;&amp;lt;asp:TreeNodeBinding DataMember="State" TargetField="checked" SelectAction=None PopulateOnDemand=true ValueField="ID" TextField="Name"&gt;&amp;lt;/asp:TreeNodeBinding&gt; &amp;lt;/DataBindings&gt;&lt;br /&gt;&amp;lt;/asp:TreeView&gt;&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;DataMember&lt;/strong&gt; property in TreeNodeBinding is used to specify the different XML elements that will be bound to the TreeView.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;ValueField&lt;/strong&gt; and &lt;strong&gt;TextField&lt;/strong&gt; properties correspond to the Xml attributes that will assign the &lt;strong&gt;Text&lt;/strong&gt; and &lt;strong&gt;Value&lt;/strong&gt; fields to each node in the TreeView.&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;TargetField&lt;/strong&gt; is here used to set the Checked state of the nodes from the corresponding Xml attribute (i.e. checked). (The TargetField in actual usage is for assigning the "target" html attribute, so that any link from the TreeView will open in the target window accordingly.)&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;SelectAction=None&lt;/strong&gt; specifies that the nodes in the TreeView do not have links or any other click action.&lt;br /&gt;&lt;br /&gt;Note the method that is called in &lt;strong&gt;OnTreeNodeDataBound&lt;/strong&gt; event. This method will basically set the checked state of the checkboxes.&lt;br /&gt;&lt;br /&gt;The following is the code for the event that has to be added in the codebehind page:&lt;br /&gt;&lt;br /&gt;protected void tvwCategories_TreeNodeDataBound(object sender, TreeNodeEventArgs e)&lt;br /&gt;{&lt;br /&gt;if (e.Node.Target == Convert.ToString("true"))&lt;br /&gt;{&lt;br /&gt;e.Node.Checked = true;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;e.Node.Checked = false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The page is now ready to be compiled and browsed. Of course, there are several ways to set the checked state of checkboxes in treeviews. However, using the above method we avoid the unnecessary for/foreach loops that may have to be used for doing the same.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114596888293586157?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114596888293586157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114596888293586157&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114596888293586157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114596888293586157'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/04/aspnet-binding-xml-data-to-treeview.html' title='ASP.NET : Binding XML Data to TreeView with Checked state of Checkboxes'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114553940374351593</id><published>2006-04-20T05:52:00.000-07:00</published><updated>2007-02-28T00:31:31.066-08:00</updated><title type='text'>ASP.NET : Export to Excel/Word from Nested GridViews</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#333399;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#333399;"&gt;Exporting a GridView to an Excel/Word is one common requirement in ASP.NET applications. In case of simple GridViews this is a pretty easy and the code for the same can be found in &lt;a href="http://lakshmik.blogspot.com/2006/01/aspnet-make-export-to-excel-always.html"&gt;my earlier article&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#333399;"&gt;&lt;br /&gt;In case of Nested GridViews, when trying to export to Word/Excel, the output comes would always be rendered inverted in Word/Excel.&lt;br /&gt;&lt;br /&gt;In this scenario, let us see how we can export the entire Nested GridView.&lt;br /&gt;&lt;br /&gt;The first step is to insert a &amp;lt;div &gt; that embeds the entire Nested GridView.&lt;br /&gt;For Ex :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;div id="divNestedGrid" runat="server"&amp;gt;&lt;br /&gt;&amp;lt;asp:GridView id=.. &amp;gt;&lt;br /&gt;...&lt;br /&gt;&amp;lt;asp:GridView .... /&amp;gt;&lt;br /&gt;---&lt;br /&gt;&amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;&amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Next step is add a hidden variable in the same aspx form.&lt;br /&gt;&lt;br /&gt;&amp;lt;input type="hidden" id="hdnInnerHtml" value="" runat="server" /&amp;gt;&lt;br /&gt;&lt;br /&gt;Now add a javascript function that in the aspx that fills the hidden variable with the inner html of the div.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;function getInnerHtml()&lt;br /&gt;{&lt;br /&gt;var element = document.getElementById("divpreview");&lt;br /&gt;var store = document.getElementById("hdnInnerHtml");&lt;br /&gt;//add the css styles you have used inside the nested GridView&lt;br /&gt;var css = "&amp;lt;style type=\"text/css\" id=\"style1\"&amp;gt;.textbold {font-family: Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;font-weight: bold;text-decoration: none;}.row1 {background-color: #FFFFFF; font-family: Arial, Helvetica, sans-serif;font-size: 11px;color: #000000;height: 18px;padding-left: 5px;}.;&lt;br /&gt;store.value = css + element.innerHTML;&lt;br /&gt;}&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Now in the Code Behind, first add the javascript function to be triggered on the click on the Export button.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;btnExport.Attributes.Add("OnClick", "getInnerHtml();");&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Finally, write the following code in the Export Button click event, to &lt;strong&gt;Export to Word&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;string html = hdnInnerHtml.Value;&lt;br /&gt;Response.Cache.SetExpires(DateTime.Now.AddSeconds(1));&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.AppendHeader("content-disposition", "attachment;filename=FileName.doc");&lt;br /&gt;Response.Charset = "";&lt;br /&gt;Response.Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;Response.ContentType = "application/vnd.ms-word";&lt;br /&gt;this.EnableViewState = false;&lt;br /&gt;Response.Write("\r\n");&lt;br /&gt;Response.Write(html);&lt;br /&gt;Response.End();&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;In case of &lt;strong&gt;Exporting to Excel&lt;/strong&gt;, you can change the code as follows:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;string html = hdnInnerHtml.Value;&lt;br /&gt;Response.Cache.SetExpires(DateTime.Now.AddSeconds(1));&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.AppendHeader("content-disposition", "attachment;filename=FileName.xls");&lt;br /&gt;Response.Charset = "";&lt;br /&gt;Response.Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;Response.ContentType = "application/vnd.ms-excel";&lt;br /&gt;this.EnableViewState = false;&lt;br /&gt;Response.Write("\r\n");&lt;br /&gt;Response.Write(html);&lt;br /&gt;Response.End();&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;In this article we discussed different ways of Exporting Data to Excel and Word when dealing with Nested Grid Views.&lt;br /&gt;&lt;br /&gt;Thanks.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114553940374351593?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114553940374351593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114553940374351593&amp;isPopup=true' title='35 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114553940374351593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114553940374351593'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/04/aspnet-export-to-excelword-from-nested.html' title='ASP.NET : Export to Excel/Word from Nested GridViews'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>35</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114320346082433710</id><published>2006-03-24T04:29:00.000-08:00</published><updated>2006-05-23T00:23:39.433-07:00</updated><title type='text'>ASP.NET 2.0 - Explicit Localization in different Languages</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;In my previous article on ASP.NET 2.0 localization, I had mentioned how easily you can localize your applications using Automatic Localization feature present in Visual Studio 2005.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;In this article let us see how we can explicitly set the localization of a page in different languages.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Let us assume we have a page in four different languages. Instead of getting the localization information from the browser settings, we will now see how we can explicitly get the same page in different languages on clicking four links (French, Spanish, German, English) on the page.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;On clicking on each of these links, the page has to get loaded in the respective languages. Let me describe how this can be achieved.&lt;br /&gt;&lt;br /&gt;The first step is to override the InitializeCulture method to load set the culture settings. To get the culture that is set by each of the Link buttons, we store the culture information in a Session object (Profile object may also be used). The following is the InitializeCulture method:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;protected override void InitializeCulture()&lt;br /&gt;{&lt;br /&gt;// override virtual method InitializeCulture() to check if session contains a language setting&lt;br /&gt;&lt;br /&gt;if (Session["PreferredCulture"] != null)&lt;br /&gt;{&lt;br /&gt;string UserCulture = Session["PreferredCulture"].ToString();&lt;br /&gt;if (UserCulture != "")&lt;br /&gt;{&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserCulture);&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;string UserCulture = ConfigurationSettings.AppSettings["ApplicationCulture"].ToString();&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserCulture);&lt;br /&gt;System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture);&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;As you can see, for the first time page loads, the culture of the page is set from the config file settings. Subsequent loads of the page after the click of each link button, we set the culture from the Session object.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Now let us see what code has to come in for each Link button click event. This event must set the selected language culture in the Session object, and then must force re-load of the page. The code is as follows for French Language:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;protected void frenchLinkButton_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;string SelectedLanguage = "fr";&lt;br /&gt;Session["PreferredCulture"] = SelectedLanguage;&lt;br /&gt;//Force re-initialization of the page to fire InitializeCulture()&lt;br /&gt;Response.Redirect(Request.Url.LocalPath);&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;The same code has to be re-written for other languages:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;For Spanish Language:&lt;br /&gt;protected void spanishLinkButton1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;string SelectedLanguage = "es";&lt;br /&gt;Session["PreferredCulture"] = SelectedLanguage;&lt;br /&gt;//Force re-initialization of the page to fire InitializeCulture()&lt;br /&gt;Response.Redirect(Request.Url.LocalPath);&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;For German Language:&lt;br /&gt;protected void germanLinkButton_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;string SelectedLanguage = "de";&lt;br /&gt;Session["PreferredCulture"] = SelectedLanguage;&lt;br /&gt;//Force re-initialization of the page to fire InitializeCulture()&lt;br /&gt;Response.Redirect(Request.Url.LocalPath);&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;For English language:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;protected void englishLinkButton_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;string SelectedLanguage = "en-US";&lt;br /&gt;Session["PreferredCulture"] = SelectedLanguage;&lt;br /&gt;//Force re-initialization of the page to fire InitializeCulture()&lt;br /&gt;Response.Redirect(Request.Url.LocalPath);&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Of course, to get the respective language page loaded, you must have the following resx files in containg text in respective languages, in your App_LocalResources folder, assuming your page is Default.aspx:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Default.aspx.es.resx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Default.aspx.fr.resx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Default.aspx.resx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;Default.aspx.de.resx&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;If you have a large application that has many pages that require explicit localization, you can have a Base class that inherits System.Web.UI.Page and put the InitializeCulture method in that Base class. All pages in your application can be made to inherit this Base class.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000099;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114320346082433710?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114320346082433710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114320346082433710&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114320346082433710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114320346082433710'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/03/aspnet-20-explicit-localization-in.html' title='ASP.NET 2.0 - Explicit Localization in different Languages'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-114077782601067499</id><published>2006-02-24T01:53:00.000-08:00</published><updated>2006-02-24T02:55:22.613-08:00</updated><title type='text'>ASP.NET 2.0  Localization - using Visual Studio 2005</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;Lot of improvements have happened in ASP.NET 2.0 with regard to localizing applications. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;br /&gt;This article will take you step by step in localizing your ASP.NET applications.For the scope of the article, we will maintain all localization entries in .resx file, although you can also maintain this using database.&lt;br /&gt;&lt;br /&gt;ASP.NET 2.0 provides the feature of automatically localizing your pages and also manual localization. Let us look at each of these.&lt;br /&gt;&lt;br /&gt;The following are the steps for &lt;strong&gt;automatic localization&lt;/strong&gt; through VS 2005:&lt;br /&gt;&lt;br /&gt;1. Complete your ASP.NET page with all controls.&lt;br /&gt;2. Switch to design view of your page from your VS 2005 IDE.&lt;br /&gt;3. From the Tools menu, click &lt;strong&gt;Generate Local Resource&lt;/strong&gt;.&lt;br /&gt;This will generate all resource strings needed for all controls on your page.&lt;br /&gt;4. Notice that your working folder will now have another folder added to it, by name App_LocalResources. This will contain the resource file for the page for which you generated Local resources.&lt;br /&gt;&lt;br /&gt;If you now look at the aspx code, you will find that, every control on the page that &lt;strong&gt;can be localizable&lt;/strong&gt; has a &lt;strong&gt;meta:resourcekey&lt;/strong&gt; attribute added to it.&lt;br /&gt;&lt;br /&gt;Now just in case you find that the &lt;strong&gt;meta:resourcekey&lt;/strong&gt; attribute has not been added to the text (this happens quite rarely - one place where I found was the Next - Previous text in a GridView), all you need to do is to add &lt;strong&gt;Key- Value&lt;/strong&gt; entry in the local resource file, say,YourPage.aspx.resx and then add this attribute to the control:&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;strong&gt;&lt;span style="font-family:trebuchet ms;"&gt;NextPageText="&lt;%$ Resources:Next %&gt;"&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;Manual Localization:&lt;br /&gt;&lt;/strong&gt;In cases where you want to dynamically assign a localized text to a string, the following are the steps: &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;br /&gt;1. Right click on your Web Project, point to &lt;strong&gt;Add ASP.NET Folder&lt;/strong&gt; and then click &lt;strong&gt;App_GlobalResources.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;2. Right click on the folder, and then click Add new Item.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;3. Choose Resource file under Templates, and name the new file as GlobalResources.resx.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;4. Add a Key - Value pair in this .resx file, say, with &lt;strong&gt;Key&lt;/strong&gt; as FName and &lt;strong&gt;Value&lt;/strong&gt; as First Name.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;5. Open the code-behind of the page in your application where you want to access this Key.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;6. Suppose you want to assign it to a label control, you must call the resource value this way:&lt;br /&gt;lblFName.Text = Resources.GlobalResources.FName;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;In the next article, we will discuss on some more points on localization configurations.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-114077782601067499?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/114077782601067499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=114077782601067499&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114077782601067499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/114077782601067499'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/02/aspnet-20-localization-using-visual.html' title='ASP.NET 2.0  Localization - using Visual Studio 2005'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-113809531896240139</id><published>2006-01-23T22:26:00.000-08:00</published><updated>2006-10-15T20:01:17.543-07:00</updated><title type='text'>ASP.NET : Make "Export to Excel" always open excel in a separate Window</title><content type='html'>&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;Export to Excel in ASP.NET is a very common feature, which I'm sure everyone who has worked in ASP.NET would have had the chance to implement. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;br /&gt;Whenever we choose the Export to Excel option from our Application, a dialog box pops us with the option to Open or to Save, as shown below:&lt;br /&gt;&lt;/span&gt;&lt;a href="http://photos1.blogger.com/blogger/1480/1052/1600/filedownload.jpg"&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1480/1052/320/filedownload.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;By chance if the user checks off the option "Always ask before opening this type of file", from next time the user will not be able to see the dialog box. Instead, the excel file opens up in the same window. &lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:Trebuchet MS;"&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;&lt;p&gt;&lt;br /&gt;To set back this option, the following steps can be followed:&lt;br /&gt;&lt;br /&gt;1. Go to Windows Explorer.&lt;br /&gt;2. On the &lt;strong&gt;Tools&lt;/strong&gt; menu, click &lt;strong&gt;Folder Options&lt;/strong&gt;, and then click on the &lt;strong&gt;File Types&lt;/strong&gt; tab.&lt;br /&gt;3. From the &lt;strong&gt;Registered file types&lt;/strong&gt; list box, select the &lt;strong&gt;XLS&lt;/strong&gt; extension, and then click &lt;strong&gt;Advanced&lt;/strong&gt;.&lt;br /&gt;4. In the &lt;strong&gt;Edit File Type&lt;/strong&gt; dialog box, set the &lt;strong&gt;Confirm open after download&lt;/strong&gt; to selected.&lt;br /&gt;5. Make sure the &lt;strong&gt;Browse in same window&lt;/strong&gt; option is &lt;strong&gt;not&lt;/strong&gt; selected, and then click &lt;strong&gt;OK&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;The above steps will make sure that we get the dialog box as shown above. However, since this is an option set at the client computer, these steps cannot be mandated to be followed in every computer that browses the application.&lt;br /&gt;&lt;br /&gt;So, from the code level, we must make sure that the excel file is opened in a separate window. One possible option for this is to Save the file to the web server, and then open the file in a separate window.&lt;br /&gt;&lt;br /&gt;The code for this is given below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;strong&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;private void ExportToExcel(DataGrid dgExport)&lt;br /&gt;{&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;string strFileName = String.Empty, strFilePath= String.Empty;&lt;br /&gt;strFilePath = Server.MapPath(@"../Excel/") + "ExcelFileName" + ".xls";&lt;br /&gt;if (File.Exists(strFilePath))&lt;br /&gt;{&lt;br /&gt;File.Delete(strFilePath);&lt;br /&gt;}&lt;br /&gt;System.IO.StringWriter oStringWriter =new StringWriter();&lt;br /&gt;System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);&lt;br /&gt;StreamWriter objStreamWriter;&lt;br /&gt;string strStyle =@" &lt;style&gt;.text { mso-number-format:\@; } &lt;/style&gt;&lt;br /&gt;";&lt;br /&gt;objStreamWriter = File.AppendText(strFilePath);&lt;br /&gt;dgExport.RenderControl(oHtmlTextWriter);&lt;br /&gt;objStreamWriter.WriteLine(strStyle);&lt;br /&gt;objStreamWriter.WriteLine(oStringWriter.ToString());&lt;br /&gt;objStreamWriter.Close();&lt;br /&gt;string strScript = "&amp;lt;script language=JavaScript&amp;gt;window.open('../Excel/" + "ExcelFileName" +&lt;br /&gt;".xls','dn','width=1,height=1,toolbar=no,top=300,left=400,right=1,&lt;/span&gt;&lt;/strong&gt; &lt;p&gt;&lt;strong&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;scrollbars=no,locaton=1,resizable=1');&amp;lt;/script&amp;gt;";&lt;br /&gt;if(!Page.IsStartupScriptRegistered("clientScript"))&lt;br /&gt;{&lt;br /&gt;Page.RegisterStartupScript("clientScript", strScript);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;catch(Exception)&lt;br /&gt;{&lt;br /&gt;//Handle Exception&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;In the above method, the file is saved to the Web Server inside the folder "Excel". Of course, this folder must have write permissions for the user. But it will definitely ensure that the excel file is opened in a new window in the client computer.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Trebuchet MS;"&gt;Cheers.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Trebuchet MS;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-113809531896240139?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/113809531896240139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=113809531896240139&amp;isPopup=true' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113809531896240139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113809531896240139'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/01/aspnet-make-export-to-excel-always.html' title='ASP.NET : Make &quot;Export to Excel&quot; always open excel in a separate Window'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-113808400283272118</id><published>2006-01-23T22:23:00.000-08:00</published><updated>2006-01-24T02:25:51.850-08:00</updated><title type='text'>Enterprise Library for .NET Framework 2.0 released</title><content type='html'>&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;Microsoft has released the Enterprise Library for .NET Framework 2.0 this month !!!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;Within just two months from the release of .NET Framework 2.0, the release of Enterprise Library for the same comes as a pleasant surprise, thanks to the hard work put by the Team.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;With just a quick glance, I could note that the following features have been added newly:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;1. In the &lt;strong&gt;DAAB (Data Access Application Block)&lt;/strong&gt;, you can dynamically create Connection strings and use them&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;2. The &lt;strong&gt;DAAB&lt;/strong&gt; includes Database-derived classes for Microsoft SQL Server and Oracle.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;3. There is something called the &lt;strong&gt;GenericDatabase&lt;/strong&gt; class in DAAB that can be used to access OLE-DB and ODBC databases. &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;4. The &lt;strong&gt;Configuration Application Block&lt;/strong&gt; has been removed and its now based on &lt;strong&gt;System.Configuration&lt;/strong&gt; namespace.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;For more details and downloading, check &lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/library/en-us/dnpag2/html/EntLib2.asp"&gt;&lt;span style="font-family:trebuchet ms;color:#000000;"&gt;http://msdn.microsoft.com/library/en-us/dnpag2/html/EntLib2.asp&lt;/span&gt;&lt;/a&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;Happy Exploring!!!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-113808400283272118?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/113808400283272118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=113808400283272118&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113808400283272118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113808400283272118'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2006/01/enterprise-library-for-net-framework.html' title='Enterprise Library for .NET Framework 2.0 released'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-113584847415156134</id><published>2005-12-28T22:51:00.000-08:00</published><updated>2006-06-12T09:51:26.160-07:00</updated><title type='text'>ASP.NET : Trigger an Event in the  Parent Page from within a Page inside IFrame</title><content type='html'>&lt;span style="font-family:trebuchet ms;"&gt;Web Applications have started dominating the traditional Windows based applications and in the process, the requirements are ever increasing and in many situations we find that too many functionalities need to come as part of a single page.&lt;br /&gt;&lt;br /&gt;At this point we resolve to break down each of these functionalities as separate pages and try to call these pages inside an IFrame. This will ensure that the page does not become too heavy and also easy maintainability.&lt;br /&gt;&lt;br /&gt;The problem starts when an event has to be triggered in the parent page after an event occurs inside the IFrame. Now let us take an example before I explain how this can be accomplished.&lt;br /&gt;&lt;br /&gt;Let us say we have a page that contains Product information. I have some ten list of options like adding categories of a Product, Viewing Product information, etc.&lt;br /&gt;&lt;br /&gt;Now for all these I want to give a singly entry system, with my Parent page where I show up all the products in a list box. On top of this I have all the ten options specified. All the other functionalities are taken to ten different pages. I keep an IFrame beside my ListBox that calls the 10 different pages.The aspx page for the Parent Page (say ProductHome.aspx) will have this code:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;&amp;lt;table class="table" height="60%" width="80%" align="center" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td width="20%" height="100%"&amp;gt;&lt;br /&gt;&amp;lt;asp:linkbutton id="lnkAddProduct" CssClass="sublink" Runat="server" text="Add a New Product"&amp;gt;&amp;lt;/asp:linkbutton&amp;gt;&lt;br /&gt;&amp;lt;asp:listbox id="lstProducts" CssClass="textbox" Runat="server" width="100%" Rows="10" AutoPostBack="True" &amp;gt;&amp;lt;/asp:listbox&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td width="80%" height="100%"&amp;gt;&amp;lt;iframe id="MyFrame" style="WIDTH: 100%; HEIGHT: 100%" name="main" src="" frameBorder="0" scrolling="yes" height="100%" runat="server"&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;On click of every product I show up the page that displays Product information. Another page is for creating a new Product. Whenever I create a new Product in a page inside an IFrame, I must be able to add that product to the ListBox in the Parent page.&lt;br /&gt;&lt;br /&gt;For this to happen, all I need to do is just a few lines of code in the code behind of the child page that contains the new Product information (let us call it AddProduct.aspx). In the Button Click Event (say btnSave_Click), after saving the information to the database:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;Session["BindProducts"] = "true";&lt;br /&gt;Session["Page"] = "AddProduct.aspx";&lt;br /&gt;Session["ShowMessage"] = "The Product was added successfully";&lt;br /&gt;Page.RegisterStartupScript("RefreshParent","&amp;lt;script language='javascript'&amp;gt;RefreshParent()&amp;lt;/script&amp;gt;");&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;All that the above code does is to refresh the parent page after setting a few Session variables.&lt;br /&gt;&lt;br /&gt;Now in the aspx page of the child page, add the following script block:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;&amp;lt;script language="javascript"&amp;gt;&lt;br /&gt;function RefreshParent()&lt;br /&gt;{&lt;br /&gt;window.parent.location.href = "ParentPage.aspx";&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;So now when the Parent Page refreshes, you must bind the ListBox again with the new Product added. For this to happen, add the following code in Page_Load event of Parent Page (ProductHome.aspx):&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;if(Session["BindProducts"] != null)&lt;br /&gt;{&lt;br /&gt;if(Session["BindProducts"].ToString() == "true")&lt;br /&gt;{&lt;br /&gt;//Call the function to Bind the Products list box again&lt;br /&gt;BindProducts();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;And now remember to set the IFrame's src attribute to your child Page with a message displaying that the Product was added successfully. This will give the end user a feeling that he is only working with the one single page. Add the following code in Page_Load event of ProductHome.aspx to set the URL of the IFrame:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;strong&gt;#region Set URL of IFrame&lt;br /&gt;if(Session["Page"] != null)&lt;br /&gt;{&lt;br /&gt;string url = Session["Page"].ToString();&lt;br /&gt;HtmlControl MyFrame = (HtmlControl)this.FindControl("MyFrame");&lt;br /&gt;MyFrame.Attributes["src"] = url;&lt;br /&gt;Session["Page"] = null;&lt;br /&gt;}&lt;br /&gt;#endregion&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Now as a last step, display the message that the Product was added in the Child Page. Add the following code in Page_Load event of the Child Page (AddProduct.aspx):&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#3333ff;"&gt;if(Session["ShowMessage"] != null)&lt;br /&gt;{&lt;br /&gt;lblVisitsAdded.Text = Session["ShowMessage"].ToString();&lt;br /&gt;Session["ShowMessage"] = null;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The above steps can be repeated for all the other functionalities.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-113584847415156134?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/113584847415156134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=113584847415156134&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113584847415156134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113584847415156134'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/12/aspnet-trigger-event-in-parent-page.html' title='ASP.NET : Trigger an Event in the  Parent Page from within a Page inside IFrame'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-113532657911161603</id><published>2005-12-22T22:05:00.000-08:00</published><updated>2005-12-27T00:36:04.016-08:00</updated><title type='text'>How To : Create a Dynamic Time Table in ASP.NET</title><content type='html'>&lt;span style="font-family:trebuchet ms;"&gt;There will be many times where you will need to have a time table in your applications.&lt;br /&gt;&lt;br /&gt;For ex. Think of a travel agency person who wants to mark that the buses/transport facilities would be available on specific times - on specific days. This availability information is prone to have frequent changes and therefore must be editable also.&lt;br /&gt;&lt;br /&gt;Lets suppose that we maintain two tables - one for number of days the bus will run on like Sunday, Monday, etc. - we will call it AvailabilityDays, and one for the timings - such as 8:30, 9:00, 9:30, 11:30, 12:30 , etc. called AvailabilityTimes.&lt;br /&gt;&lt;br /&gt;All we need is an editable grid with checkboxes, with columns as AvailabilityTimes and rows as the AvailabilityDays.&lt;br /&gt;&lt;br /&gt;The first step is to get data through a Stored Procedure into a DataSet. The following code gets the code into a DataSet from an SP that has just 2 select statements from the&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;&lt;span style="color:#330099;"&gt;DataTable avDaysTable = new DataTable();&lt;br /&gt;DataTable avTimeTable = new DataTable();&lt;br /&gt;DataSet ds = new DataSet();&lt;br /&gt;SqlConnection sqlCon = new SqlConnection("server=[servername];uid=[username];pwd=[password];database=[database]");&lt;br /&gt;SqlCommand cmd = new SqlCommand("GetAvailabilityDaysAndTime",sqlCon);&lt;br /&gt;cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);&lt;br /&gt;dAdapter.Fill(ds);&lt;br /&gt;avDaysTable = ds.Tables[0];&lt;br /&gt;avTimeTable = ds.Tables[1];&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Now that we have two datatables with Days and Times, we now need to construct a dynamic table containing these. For that we first declare an empty table in the aspx page:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#330099;"&gt;&lt;?xml:namespace prefix = asp /&gt;&lt;asp:table id="MyTable" gridlines="Both" borderstyle="Ridge" name="Arial" size="10" runat="server" height="50%" width="100%" cssclass="sub-heading"&gt;&lt;/asp:table&gt;&lt;/span&gt;&lt;span style="color:#330099;"&gt;&lt;strong&gt;&amp;lt;asp:table CssClass="sub-heading" id="MyTable" Width="100%" Height="50%" Runat="server" Font-Size="10" Font-Name="Arial" BorderStyle="Ridge" GridLines="Both"&amp;gt;&amp;lt;/asp:table&amp;gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#330099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Now to build the dynamic time table, we first take the count of the columns that need to come, and first construct the header row with the number of columns.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color:#330099;"&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;int columnCount = avTimeTable.Rows.Count;&lt;br /&gt;TableItemStyle tableStyle = new TableItemStyle();&lt;br /&gt;tableStyle.HorizontalAlign = HorizontalAlign.Center;&lt;br /&gt;tableStyle.VerticalAlign = VerticalAlign.Middle;&lt;br /&gt;tableStyle.Width = Unit.Pixel(100);&lt;br /&gt;tableStyle.CssClass = "button-editable-heading";&lt;br /&gt;&lt;br /&gt;TableRow headerrow;&lt;br /&gt;TableCell headerCell;&lt;br /&gt;headerCell = new TableCell();&lt;br /&gt;headerCell.Text = "";&lt;br /&gt;headerrow = new TableRow();&lt;br /&gt;headerrow.Cells.Add(headerCell);&lt;br /&gt;for(int i=0;i&amp;lt;avTimeTable.Rows.Count;i++)&lt;br /&gt;{&lt;br /&gt;headerCell = new TableCell();&lt;br /&gt;headerCell.Text = avTimeTable.Rows[i][1].ToString();&lt;br /&gt;headerrow.Cells.Add(headerCell);&lt;br /&gt;}&lt;br /&gt;headerrow.ApplyStyle(tableStyle);&lt;br /&gt;MyTable.Rows.Add(headerrow);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Next, for each of the columns in the header, we now need to add as many number of days as in the AvailabilityDays table. This will constitute the rows of the table. To each of these rows, we also need to add a Checkbox so that the availability for a day and for a particular time can be set. Finally, add these rows to the main table to complete the time table grid.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family:trebuchet ms;"&gt;CheckBox chk;&lt;br /&gt;for(int i=0;i&amp;lt;avDaysTable.Rows.Count;i++)&lt;br /&gt;{&lt;br /&gt;//add rows to first column&lt;br /&gt;headerrow = new TableRow();&lt;br /&gt;headerrow.ID = i.ToString();&lt;br /&gt;headerCell = new TableCell();&lt;br /&gt;headerCell.Text = avDaysTable.Rows[i][1].ToString();&lt;br /&gt;headerCell.ApplyStyle(tableStyle);&lt;br /&gt;headerrow.Cells.Add(headerCell);&lt;br /&gt;for(int j=0;j&amp;lt;avTimeTable.Rows.Count;j++)&lt;br /&gt;{&lt;br /&gt;headerCell = new TableCell();&lt;br /&gt;chk = new CheckBox();&lt;br /&gt;chk.ID = "chk" + i.ToString() + j.ToString();;&lt;br /&gt;headerCell.Controls.Add(chk);&lt;br /&gt;headerrow.Cells.Add(headerCell);&lt;br /&gt;}&lt;br /&gt;MyTable.Rows.Add(headerrow);&lt;br /&gt;}&lt;br /&gt;MyTable.Rows.Add(headerrow);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="color:#000000;"&gt;Thats it. We now have a time table grid ready to take the values for any day any time. In the next article, I'll explain how we can store and retrieve values in the time table.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#330099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#330099;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-113532657911161603?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/113532657911161603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=113532657911161603&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113532657911161603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113532657911161603'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/12/how-to-create-dynamic-time-table-in.html' title='How To : Create a Dynamic Time Table in ASP.NET'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-113524195168592209</id><published>2005-12-22T00:41:00.000-08:00</published><updated>2005-12-22T01:01:27.240-08:00</updated><title type='text'>How to : Get Excel data into a .NET DataSet object</title><content type='html'>There may be requirement where in data in an Excel sheet has to be manipulated inside .NET Applications. Although there are many ways to achieve this (like using Excel object of COM), the most preferred way is to use the .NET Data providers to achieve this.&lt;br /&gt;&lt;br /&gt;The following is a sample code that can be used to get Excel data into a .NET Dataset object.&lt;br /&gt;&lt;br /&gt;The parameter &lt;strong&gt;excelSheetName &lt;/strong&gt;in the below method is the name of the Excel sheet and the sheetNumber parameter indicates the number of the sheet (out of all the sheets in an Excel file).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;color:#000099;"&gt;public DataSet RetrieveExcelData(string excelSheetName,int sheetNumber)&lt;br /&gt;{&lt;br /&gt;OleDbConnection objConn = null;&lt;br /&gt;System.Data.DataTable dt = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;// Connection String.&lt;br /&gt;String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +&lt;br /&gt;"Data Source=" + excelSheetName + ";Extended Properties=Excel 8.0;";&lt;br /&gt;// Create connection object by using the preceding connection string.&lt;br /&gt;objConn = new OleDbConnection(connString);&lt;br /&gt;// Open connection with the database.&lt;br /&gt;objConn.Open();&lt;br /&gt;// Get the data table containg the schema guid.&lt;br /&gt;dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);&lt;br /&gt;if(dt == null)&lt;br /&gt;{&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;String[] excelSheets = new String[dt.Rows.Count];&lt;br /&gt;int i = 0;&lt;br /&gt;// Add the sheet name to the string array.&lt;br /&gt;foreach(DataRow row in dt.Rows)&lt;br /&gt;{&lt;br /&gt;excelSheets[i] = row["TABLE_NAME"].ToString();&lt;br /&gt;i++;&lt;br /&gt;if(i==sheetNumber)&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;OleDbCommand excelCommand = new OleDbCommand("Select * from ["+excelSheets[sheetNumber-1]+"]",objConn);&lt;br /&gt;OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);&lt;br /&gt;DataSet excelDataSet = new DataSet();&lt;br /&gt;excelAdapter.Fill(excelDataSet);&lt;br /&gt;return excelDataSet;&lt;br /&gt;}&lt;br /&gt;catch(OleDbException ex)&lt;br /&gt;{&lt;br /&gt;throw ex;&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;throw ex;&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;// Clean up.&lt;br /&gt;if(objConn != null)&lt;br /&gt;{&lt;br /&gt;objConn.Close();&lt;br /&gt;objConn.Dispose();&lt;br /&gt;}&lt;br /&gt;if(dt != null)&lt;br /&gt;{&lt;br /&gt;dt.Dispose();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;color:#000099;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000099;"&gt;&lt;span style="color:#000000;"&gt;Through the above method, we avoid the extra reference of the COM dll and also get the flexibility of manipulating Excel shett data through ADO.NET.&lt;/span&gt; &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-113524195168592209?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/113524195168592209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=113524195168592209&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113524195168592209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/113524195168592209'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/12/how-to-get-excel-data-into-net-dataset.html' title='How to : Get Excel data into a .NET DataSet object'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-112593116374852993</id><published>2005-09-05T06:54:00.000-07:00</published><updated>2005-09-05T07:39:23.766-07:00</updated><title type='text'>ASP.NET TextBox, Trim White Spaces within words</title><content type='html'>ASP.NET TextBox provides a lot of features which reduces many a plumbing work required in previous versions of HTML Input Type.&lt;br /&gt;&lt;br /&gt;Some of the built-in functionalities of &amp;lt;asp:textbox&amp;gt; such as TextMode to specify whether it is a Text field, a password field or Text Area simplify the programming task and provide meaningful interfaces to work with.&lt;br /&gt;&lt;br /&gt;One of the important tasks we do when receiving user input in TextBox is to Trim the white spaces entered by the users.  This can very well minimize the size of the data as well as storage in DataStores.&lt;br /&gt;&lt;br /&gt;Some of the built-in methods that ship with the string class are&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;string.TrimStart() &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Removes the specified set of occurances from the Beginning of the string&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;string.TrimEnd()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Removes the specified set of occurances from the End of the string&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;string.Trim()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Removes White Spaces from Beginning &amp; End of the string.  Very useful in applications while retrieving user input to remove the white spaces.&lt;br /&gt;&lt;br /&gt;To utilize the above functions with TextBox input entered by the users, we can simply pass &lt;strong&gt;TextBox1.Text.Trim()&lt;/strong&gt;.  Since TextBox1.Text returns a string of the text entered by the user.&lt;br /&gt;&lt;br /&gt;However, if we would like to trim the extra white spaces entered by the users in the TextBox in the form of a sentence etc., then the above methods would'nt be useful.&lt;br /&gt;&lt;br /&gt;Say the user has entered &lt;strong&gt;"This&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  Word"&lt;/strong&gt;.  We would like to save it/process it as "&lt;strong&gt;This is a Word&lt;/strong&gt;", with the extra white spaces trimmed off.&lt;br /&gt;&lt;br /&gt;To do that, we can use RegularExpressions.  The following code demonstrates how we can remove extra white spaces recursively between words.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;using System.Text.RegularExpressions;&lt;br /&gt;&lt;br /&gt;private string RemoveSpaces(string str)&lt;br /&gt;{&lt;br /&gt; string result = "";&lt;br /&gt; Regex regulEx = new Regex(@"[\s]+");&lt;br /&gt; result = regulEx.Replace(str," ");&lt;br /&gt; return result;&lt;br /&gt;}&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;The above function receives a string and trims all the occurances of extra white spaces between words.&lt;br /&gt;&lt;br /&gt;So, an input of &lt;strong&gt;"This&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  Word"&lt;/strong&gt; will return the output as "&lt;strong&gt;This is a Word&lt;/strong&gt;"&lt;br /&gt;&lt;br /&gt;Thanks&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-112593116374852993?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/112593116374852993/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=112593116374852993&amp;isPopup=true' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112593116374852993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112593116374852993'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/09/aspnet-textbox-trim-white-spaces.html' title='ASP.NET TextBox, Trim White Spaces within words'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-112322869340282906</id><published>2005-08-05T00:55:00.000-07:00</published><updated>2006-06-22T19:41:21.460-07:00</updated><title type='text'>Exception Management Strategy for N-tier Applications - Part III</title><content type='html'>This article is in continuation of my previous two posts on Exception Management Strategy for N-tier Applications. If you havent read them, please check &lt;a href="http://lakshmik.blogspot.com/2005/07/exception-management-strategy-for-n.html"&gt;Part I&lt;/a&gt; and &lt;a href="http://lakshmik.blogspot.com/2005/08/exception-management-strategy-for-n_05.html"&gt;Part II&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Code Snipped Continued ...&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;The sample code for wrapping an exception that is caused in the DAL is shown below:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;try&lt;br /&gt;{&lt;/strong&gt;// statements that access SQL Server&lt;br /&gt;}&lt;br /&gt;&lt;strong&gt;catch(SqlException sqlEx)&lt;br /&gt;{&lt;br /&gt;DataOperationFailedException dataOp = new DataOperationFailedException(sqlEx.Message,sqlEx);&lt;br /&gt;dataOp.ErrorNumber = sqlEx.Number;&lt;br /&gt;dataOp.SqlServerName = sqlEx.Server.ToString();&lt;br /&gt;dataOp.ActionTaken = "";&lt;br /&gt;dataOp.LogonUser = "";&lt;br /&gt;dataOp.MstrStacktrace = sqlEx.StackTrace;&lt;br /&gt;dataOp.ContextInfo = "MyNamespace.MyClass"; &lt;/strong&gt;&lt;br /&gt;//Publish exception&lt;br /&gt;&lt;strong&gt;ExceptionSQLPublisher.Publish(dataOp);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;//Rethrow exception&lt;br /&gt;&lt;strong&gt;throw dataOp;&lt;br /&gt;}&lt;/strong&gt;&lt;br /&gt;The same way each module in the application can be wrapped suitably and the exception rethrown to above layer.&lt;br /&gt;&lt;br /&gt;If the Web.config is configured to take to a specific error page, customized error messages for each type of exception cannot be shown.&lt;br /&gt;&lt;br /&gt;So, the global.asax can be used to show customized error messages by finding the exception type that occured in the application. Here is the sample code:&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;protected void Application_Error(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Exception ex = Server.GetLastError().InnerException;&lt;br /&gt;if(ex.GetType().ToString()== "Microsoft.ApplicationBlocks.&lt;br /&gt;ExceptionManagement.DataOperationFailedException")&lt;br /&gt;{&lt;br /&gt;Response.Redirect(@"..\Error.aspx?Type=Data");&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-112322869340282906?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/112322869340282906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=112322869340282906&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112322869340282906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112322869340282906'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/08/exception-management-strat_112322869340282906.html' title='Exception Management Strategy for N-tier Applications - Part III'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-112322557834063606</id><published>2005-08-05T00:04:00.000-07:00</published><updated>2006-06-22T19:45:05.510-07:00</updated><title type='text'>Exception Management Strategy for N-tier Applications - Part II</title><content type='html'>The previous article explained how important it is to have a Base exception class that can be used through out your application. In this article, let us examine what Exception Management stategy can be built for these Enterprise Applications. Let us suppose that the strategy we design must take care of the following points:&lt;br /&gt;1. Any Exception raised in any of the Layers must be Logged. 2. The custom error page exposed by the Presentation Layer must also indicate some sort of context information (Either about the Module or some specific type of exception).&lt;br /&gt;&lt;br /&gt;The second point is important because in a large application, its certainly difficult to track which module caused the exception. So if the custom error page contains some context specific information about the module that caused the exception, handling the exception would be easy.&lt;br /&gt;&lt;br /&gt;So taking into consideration the above points, the following strategy can be designed:&lt;br /&gt;&lt;br /&gt;1. Design specific custom Exception classes for each module that inherits from the MyAppBaseApplicationException class. Any exception that occurs in that module will be wrapped using this Exception class.&lt;br /&gt;&lt;br /&gt;2. Any exception that occurs throught out your application will therefore be wrapped with the corresponding class and logged. Once the exception is logged, the isLogged flag of the base exception class will be set to true.This will avoid logging again on the higher layers.&lt;br /&gt;&lt;br /&gt;3. The logging will happen to the database by default and if the database access fails, the error messages will be logged to Windows event log.&lt;br /&gt;&lt;br /&gt;4. After the exceptions are logged the wrapped exceptions are then re-thrown to the next higher layer.&lt;br /&gt;&lt;br /&gt;5. In the final layer, you will therefore have only the wrapped exceptions or the exception that occurs in the Presentation layer.&lt;br /&gt;&lt;br /&gt;6. The custom error page in the Presentation layer can be shown with customised error messages for each module.&lt;br /&gt;&lt;br /&gt;A sample custom exception class for the Data Access module is shown below:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;public class DataOperationFailedException:MSTRBaseApplicationException&lt;br /&gt;{&lt;br /&gt;#region Fields&lt;br /&gt;private int sqlErrorNumber;&lt;br /&gt;private string sqlServerName;&lt;br /&gt;private string storedProcName;&lt;br /&gt;private int lineNumber;&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt;#region Properties&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;//Add properties to access the private variables&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;#endregion&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Code Snippet Continued in my &lt;a href="http://lakshmik.blogspot.com/2005/08/exception-management-strat_112322869340282906.html"&gt;Next Post.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-112322557834063606?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/112322557834063606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=112322557834063606&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112322557834063606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112322557834063606'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/08/exception-management-strategy-for-n_05.html' title='Exception Management Strategy for N-tier Applications - Part II'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-112261601794330681</id><published>2005-07-28T22:34:00.000-07:00</published><updated>2006-06-22T19:32:33.400-07:00</updated><title type='text'>Exception Management Strategy for N-tier Applications - Part I</title><content type='html'>In this article, which is spread across two parts, I would like to discuss about how effectively exceptions can be managed Enterprise applications spread across N-Tiers.&lt;br /&gt;&lt;br /&gt;In any application that uses Enterprise Architecture, managing exceptions forms a critical requirement. To build successful and flexible applications that can be maintained and supported easily, an appropriate exception management strategy must be adopted.&lt;br /&gt;&lt;br /&gt;Now what are exceptions, by the way?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Exceptions&lt;/strong&gt; represent a breach of an implicit assumption made within code.&lt;br /&gt;&lt;br /&gt;For example, if your code tries to access a file that is assumed to exist, but the file is missing, an exception would be thrown. However, if your code does not assume that the file exists and checks for its presence first, this scenario would not necessarily generate an exception.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Microsoft Application Blocks&lt;/strong&gt; are generally used for Enterprise Applications to manage Exceptions. The Application Blocks provide a set of APIs that can be directly used for managing exceptions. If your application is complex and spread across manylayers, we can build a custom application class that uses these Application Blocks for handling exceptions.&lt;br /&gt;&lt;br /&gt;Now let us suppose we have the following layers in our Application:&lt;br /&gt;1. Data Access Layer (DAL)&lt;br /&gt;2. Business Layer (BL)&lt;br /&gt;3. Business Facade Layer(BFL)&lt;br /&gt;4. Presentation Layer (PL)&lt;br /&gt;&lt;br /&gt;and with these layers, we also have class library that contains the Microsoft Application Blocks for Exception Management.&lt;br /&gt;&lt;br /&gt;To this library we will add our custom Base Exception class say, MyAppBaseApplicationException class.&lt;br /&gt;This MyAppBaseApplicationException class will inherit from BaseApplicationException that comes with the Exception Management Block. The following is the sample code that can be used for MyAppBaseException:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Summary description for MyAppBaseApplicationException.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;&lt;strong&gt;public class MyAppBaseApplicationException:CognizantBaseAppException&lt;br /&gt;{&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;#region Fields&lt;/strong&gt;&lt;strong&gt;private int errorNumber;&lt;/strong&gt; //The error number assigned by sql or by the .net framework&lt;br /&gt;&lt;strong&gt;private string actionTaken; &lt;/strong&gt;//The task being performed when the exception occurred&lt;br /&gt;&lt;strong&gt;private string contextInfo;&lt;/strong&gt; //A field to be used to get the context in which the &lt;strong&gt;exception occured&lt;br /&gt;private bool exceptionHandled;&lt;/strong&gt; //Indicates whether or not the exception has been handled&lt;br /&gt;&lt;strong&gt;private bool displayToClient;&lt;/strong&gt; //Indicates whether or not the end user should see the exception details.&lt;br /&gt;&lt;strong&gt;private string logonUser;&lt;/strong&gt; //The user of the system when the exception occurred.&lt;br /&gt;&lt;strong&gt;private string exceptionDate;&lt;/strong&gt; //The date and time when the exception occurred.&lt;br /&gt;&lt;strong&gt;private bool isLogged;//&lt;/strong&gt;Indicates if the exception is logged to SQL Server&lt;br /&gt;&lt;strong&gt;private string mstrStackTrace;//&lt;/strong&gt;For stack trace&lt;br /&gt;&lt;strong&gt;#endregion&lt;/strong&gt; //Private Data Members&lt;br /&gt;&lt;strong&gt;#region Constructors&lt;/strong&gt;&lt;br /&gt;&lt;summary&gt;&lt;br /&gt;/// Constructor with exception id and inner exception&lt;br /&gt;&lt;/param&gt;&lt;strong&gt;public MyAppBaseApplicationException(string message, Exception inner) : base(message,inner)&lt;br /&gt;{&lt;br /&gt;Initialize();&lt;br /&gt;}&lt;/strong&gt;&lt;br /&gt;///Add other constructors if needed&lt;br /&gt;&lt;strong&gt;#endregion&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;#region Properties&lt;br /&gt;&lt;/strong&gt;///Add properties to access the private members&lt;br /&gt;&lt;strong&gt;#endregion &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;You may need to add additional properties pertaining to your application. The &lt;strong&gt;isLogged&lt;/strong&gt; flag is important as it indicates if a specific exception has been logged or not. This is necessary when your Application is spread across many layers.&lt;br /&gt;&lt;br /&gt;Having written the Base class, the &lt;a href="http://lakshmik.blogspot.com/2005/08/exception-management-strategy-for-n_05.html"&gt;next article&lt;/a&gt; will concentrate on how to use this MyAppBaseApplicationException class and how we log the exceptions in all the four layers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-112261601794330681?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/112261601794330681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=112261601794330681&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112261601794330681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/112261601794330681'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/07/exception-management-strategy-for-n.html' title='Exception Management Strategy for N-tier Applications - Part I'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111933755450913918</id><published>2005-06-21T00:04:00.000-07:00</published><updated>2006-10-22T10:05:45.556-07:00</updated><title type='text'>Points to consider to increase performance in ADO.NET – Part II</title><content type='html'>In my previous article, ten points on the general considerations on increasing the performance of ADO.NET were discussed. Let us examine in more detail on other factors that affect the performance.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Use of Transactions&lt;/strong&gt;&lt;br /&gt;Transactions are important for ensuring data integrity. But they can also have an operational cost if they are not rightly used. You must select the right transaction management mechanism for your application to significantly improve scalability and performance.&lt;br /&gt;The following points should be remembered during your decision of using transactions:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;a) Use SQL transactions when:&lt;br /&gt;· You need server controlled transactions&lt;br /&gt;· You can complete the transaction operation on a single data store in just one simple call to the datastore&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;b) Use ADO.NET transactions when:&lt;br /&gt;· You need client-controlled transactions&lt;br /&gt;· When you want to make multiple calls to a single datastore&lt;br /&gt;c) Keep transactions as short as possible with as little code as possible to avoid locks.&lt;br /&gt;d) Use the appropriate isolation level.&lt;br /&gt;SQL Server and other database systems support various levels of isolation for transactions. Isolation shields database operations from the effect of other concurrent transactions.&lt;br /&gt;There are basically four levels of isolation-&lt;br /&gt;· Read uncommitted,&lt;br /&gt;· Read committed,&lt;br /&gt;· Repeatable read&lt;br /&gt;· Serializable&lt;br /&gt;&lt;br /&gt;The highest isolation level, &lt;strong&gt;serializable&lt;/strong&gt;, reduces concurrency and provides the highest level of data integrity.&lt;br /&gt;The lowest isolation level, &lt;strong&gt;read uncommitted&lt;/strong&gt;, gives the opposite result.&lt;br /&gt;&lt;br /&gt;By selecting the correct level of isolation that pertains to your application, you can improve performance and scalability.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Avoid code that can lead to deadlock.&lt;br /&gt;&lt;/strong&gt;Sometimes your code may get trapped in a deadlock when it is highly data centric. To avoid deadlocks, always access tables in the same order across transactions in your application. The likelihood of a deadlock increases when you access tables in a different order each time you access them.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Consider SET NOCOUNT ON for SQL Server&lt;br /&gt;&lt;/strong&gt;When you use SET NOCOUNT ON, the message that indicates the number of rows that are affected by the T-SQL statement is not returned as part of the results. When you use SET NOCOUNT OFF, the count is returned. Using SET NOCOUNT ON can improve performance because network traffic can be reduced.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. The Parameter Collection&lt;/strong&gt;&lt;br /&gt;Use the Parameters collection when you call a stored procedure and when you build SQL commands. Also ensure that you explicitly set the data type for each parameter. This will avoid the round trips to server by checking the data type on the client and the likelihood that the Parameter object could set an invalid type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Cache stored procedure SqlParameter objects. &lt;/strong&gt;&lt;br /&gt;Often, applications must run commands multiple times. To avoid recreating the SqlParameter objects each time, cache them so that they can be reused later. You can use a Hashtable object to cache SqlParameter objects.&lt;br /&gt;For code samples for the parameter caching approach, check out this link:&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. Avoid moving Binary Large Objects Repeatedly&lt;br /&gt;&lt;/strong&gt;Avoid moving BLOB data more than one time from the server to client and vice versa.&lt;br /&gt;For example, if you build a Web application that serves images, store the images on the file system and the file names in the database instead of storing the images as BLOBs in the database. Storing the images as BLOBs in the database means that you must &lt;strong&gt;read&lt;/strong&gt; the BLOB from the database to the Web server and then &lt;strong&gt;send&lt;/strong&gt; the image from the Web server to the browser. Reading the file name from the database and having the Web server send the image to the browser reduces the load on the database server.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. Paging Records&lt;br /&gt;&lt;/strong&gt;Paging records is a common application scenario. The records that you need to page through can often be based on user input. For example, they can be based on a search keyword entered through a search screen. Or, the records can be common to all users, like a product catalogue.&lt;br /&gt;&lt;br /&gt;There are two basic approaches to paging:&lt;br /&gt;· You can return the &lt;strong&gt;whole&lt;/strong&gt; result set from the database to the client. The client caches the result set and then displays the most relevant results to the user by using the correct filtering mechanism. But this will involve processing cost at the client and memory for caching.&lt;br /&gt;&lt;br /&gt;· You can have the database assume the additional role of a filter by making the database return only the most relevant result set to the client. This will involve network cost for the amount of data sent across the network.&lt;br /&gt;&lt;br /&gt;Depending upon the type of application and load on the server, we must try to decide the best between the above two approaches.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Exception Management&lt;br /&gt;&lt;/strong&gt;a) Avoid relying on an Exception error handler to detect connection state availability. use the &lt;strong&gt;ConnectionState.Open&lt;/strong&gt; or &lt;strong&gt;ConnectionState.Close&lt;/strong&gt; method to check the state before use.&lt;br /&gt;&lt;br /&gt;b) Use &lt;strong&gt;try/finally&lt;/strong&gt; more often than &lt;strong&gt;try/catch/finally&lt;/strong&gt;. Using finally gives you the option to close the connection, even if an exception occurs.&lt;br /&gt;&lt;br /&gt;c) Use &lt;strong&gt;specific&lt;/strong&gt; handlers to catch specific exceptions. For example, if you know that your code may cause an SqlException, use &lt;strong&gt;catch(SqlException sqlEx)&lt;/strong&gt; and then use a generic exception handler like &lt;strong&gt;catch(Exception ex).&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I have covered most of the points I've learnt on increasing performance in ADO.NET.&lt;br /&gt;One interesting topic which remains to be addressed is about the best use of DataSet and DataReader, which I think is addressed in numerous articles on web. Here is one:&lt;br /&gt;&lt;a href="http://geekswithblogs.net/ranganh/archive/2005/04/25/37618.aspx"&gt;http://geekswithblogs.net/ranganh/archive/2005/04/25/37618.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111933755450913918?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111933755450913918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111933755450913918&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111933755450913918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111933755450913918'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/06/points-to-consider-to-increase.html' title='Points to consider to increase performance in ADO.NET – Part II'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111899379441970898</id><published>2005-06-16T22:38:00.000-07:00</published><updated>2005-06-17T00:36:34.426-07:00</updated><title type='text'>Ten points to consider to increase performance in ADO.NET</title><content type='html'>Here is a consolidated list of how you can improve the performance of your .NET apps:&lt;br /&gt;&lt;br /&gt;1.  &lt;strong&gt;Design your data access layer based on how the data is used&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;In larger applications, it’s always better to go for a separate Data Access Layer (DAL) to abstract the underlying data store complexity and to provide a logical separation. Having the data access logic in the same presentation layer may increase performance but at the cost of maintainability.&lt;br /&gt;&lt;br /&gt;You can use the &lt;strong&gt;Microsoft Application Blocks&lt;/strong&gt; for simplifying your tasks of Data Access and Exception handling. (I personally prefer this)&lt;br /&gt;&lt;br /&gt;2.  &lt;strong&gt;Cache your data to avoid unnecessary round trips and network overhead. &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Try to cache data that is used across your application, in the layer that is close to the consumer of data. This will reduce the latency in network to fetch data. Note that if your data in cache needs to be updated too frequently, then better you don’t cache that data.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Acquire late, release early.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Open database connections right only when you need them. Close the database connections as soon as you are finished.  Acquire locks late, and release them early.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;4.  Close disposable resources.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Make sure that you call either the Dispose or Close method on resources that are disposable, as soon as you are finished with using the resource.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;5. Reduce round trips.&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;   · If you have some 3 or 4 SQL statements, try to use batch sql statements in a stored procedure to decrease round trips.&lt;br /&gt;   · Use ExecuteScalar method for getting a single result.&lt;br /&gt;   · Use ExecuteNonQuery method when you want to execute any DDL statement.&lt;br /&gt;   · Use connection pooling to help avoid extra round trips. By reusing connections from a connection pool, you can avoid the round trips that are associated with connection establishment and authentication.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6.Return only the data you need.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Evaluate the data that your application actually requires and return only that data. This will minimize the bandwidth consumption in the network.&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;7. Use Windows authentication.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;From a security perspective, use Windows authentication instead of SQL authentication. This ensures that credentials are not passed over the network, database connection strings do not contain credentials, and you can apply standard Windows security policies to accounts. Remember to use connection pooling with your connection.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;8. Use stored procedures. &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Avoid embedded SQL statements and use Store Procedures (SP) instead. This has the following advantages:&lt;br /&gt;           · A Logical separation of Data access code from your Business Logic code&lt;br /&gt;           ·  Queries can be optimized for performance from SQL server&lt;br /&gt;           · Deployment becomes easier as, for any change in SP you don’t need to redeploy you application.&lt;br /&gt;           · SPs allow the batch execution of SQL commands&lt;br /&gt;           · You can impose specific restrictions on selected stored procedures for security reasons. This is very difficult to be done from embedded SQL.&lt;br /&gt;           · You can avoid the most dangerous SQL Injection by using parameterized SPs.&lt;br /&gt;&lt;br /&gt;9. &lt;strong&gt; Consider how to handle exceptions.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;You can use try/finally blocks to ensure that connections and other resources are closed, regardless of whether exceptions are generated or not. The best way for abstracting all exceptions from user is to log them to a file or Windows Event log.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;10. Use appropriate normalization.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;You  may want a normalized database to minimize data duplication but be aware that you don’t over-normalize. This can affect the performance and scalability of your application&lt;br /&gt;&lt;br /&gt;The above list is purely based on my working experience and there are many more points to add to this, which I’ll be adding in the next part of this article.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111899379441970898?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111899379441970898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111899379441970898&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111899379441970898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111899379441970898'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/06/ten-points-to-consider-to-increase.html' title='Ten points to consider to increase performance in ADO.NET'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111865881885097527</id><published>2005-05-13T02:57:00.000-07:00</published><updated>2005-06-13T03:33:38.853-07:00</updated><title type='text'>What are Application Domains?</title><content type='html'>Many of us have come across the word "&lt;strong&gt;Application Domains&lt;/strong&gt;" during our projects. But mostly I have seen many people having a wrong notion on what Application Domains really are.&lt;br /&gt;Now lets examine what these &lt;strong&gt;App Domains&lt;/strong&gt; are.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Application domains&lt;/strong&gt; are basically logical boundaries which provide a secure, versatile unit of processing that the Common Language Runtime (CLR)  uses to provide isolation between applications.&lt;br /&gt;&lt;br /&gt;Thus, you can run several application domains in a single process with the same level of isolation that would exist in &lt;strong&gt;separate&lt;/strong&gt; processes, but &lt;strong&gt;without&lt;/strong&gt; incurring the additional overhead of making cross-process calls or switching between processes.&lt;br /&gt;The ability to run multiple applications within a single process dramatically increases server scalability.&lt;br /&gt;&lt;br /&gt;Thus, the Application domains provide an isolation that has the following advantages:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Application Security&lt;/li&gt;&lt;li&gt;Faults in one application cannot affect other applications. &lt;/li&gt;&lt;li&gt;Individual applications can be stopped without stopping the entire process. &lt;/li&gt;&lt;li&gt;Code running in one application cannot directly access code or resources from another application. The CLR enforces this isolation by preventing direct calls between objects in different application domains. &lt;/li&gt;&lt;li&gt;The Scope of the code is controlled by the Application domain. The Application domain provides configuration settings such as application version policies, the location of any remote assemblies it accesses, and information about where to locate assemblies that are loaded into the domain.&lt;/li&gt;&lt;li&gt;The Permissions granted to code can be controlled by the application domain in which the code is running.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111865881885097527?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111865881885097527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111865881885097527&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111865881885097527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111865881885097527'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/05/what-are-application-domains.html' title='What are Application Domains?'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111805414834922306</id><published>2005-05-06T03:31:00.000-07:00</published><updated>2007-02-14T23:03:42.750-08:00</updated><title type='text'>HOW TO: Programmatically create SSIS packages using Whidbey</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;If you had read my last two articles, you would now be familiar with SSIS and how to create simple packages Business Intelligence Development Studio.&lt;br /&gt;&lt;br /&gt;In this article, let us now check how to programmatically create a package/edit an existing package using the APIs provided with SQL Server 2005.&lt;br /&gt;&lt;br /&gt;Let us start with creating a simple Console Application in Whidbey.&lt;br /&gt;&lt;br /&gt;First of all, we need to add the following references to your Whidbey project:&lt;br /&gt;&lt;br /&gt;1. Microsoft.SqlServer.DTSPipelineWrap.dll&lt;br /&gt;2. Microsoft.SQLServer.DTSRuntimeWrap.dll&lt;br /&gt;3. Microsoft.SQLServer.ManagedDTS.dll&lt;br /&gt;&lt;br /&gt;The reference dlls can be found in the following location:&lt;br /&gt;&lt;drive&gt;C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies&lt;br /&gt;&lt;br /&gt;You must then add the namespace references in the Program.cs file as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;#region Using directives&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using Microsoft.SqlServer.Dts.Runtime;&lt;br /&gt;using Microsoft.SqlServer.Dts.Pipeline.Wrapper;&lt;br /&gt;#endregion&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;An SSIS package can be created using the Package class present in the Microsoft.SqlServer.Dts.Runtime namespace as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;Package pkg = new Package();&lt;br /&gt;pkg.Name = "MyCreatedPackage";&lt;br /&gt;pkg.ID = "MyPackageID";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now lets see how to take an existing package, modify its properties and save the package to your file system or to Yukon server.&lt;br /&gt;&lt;br /&gt;We begin with defining a Package object and an Application object.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;Package pkg = new Package();&lt;br /&gt;Application a = new Application();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;strong&gt;Application&lt;/strong&gt; class is used to discover and access Package objects.&lt;br /&gt;Next we declare the &lt;strong&gt;MainPipe&lt;/strong&gt; interface which is used to programmatically configure the data flow task. The &lt;strong&gt;IDTSComponentMetaData90&lt;/strong&gt; Interface contains the definition of a data flow component; including the custom properties, inputs, outputs, and input and output columns defined on a data flow component.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;IDTSComponentMetaData90 oledbSource;&lt;br /&gt;IDTSComponentMetaData90 oledbDestination;&lt;br /&gt;MainPipe dataFlow;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In case you are trying to modify the properties of an existing package, you must first load the external package that you already have as a template.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;pkg = a.LoadPackage(@"C:\TestPackages\MyPackage.dtsx", null);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#000000;"&gt;You must now add the connection using the ConnectionManager class and set connection properties. The ConnectionManager class contains all the information necessary to connect to a single type of data source.&lt;/span&gt;&lt;br /&gt;//Add connections&lt;br /&gt;ConnectionManager conMgr = pkg.Connections.Add("OLEDB");&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;br /&gt;/// Set stock properties&lt;br /&gt;conMgr.Name = "OLEDBConnection";&lt;br /&gt;conMgr.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=mdpkb2e139;Auto Translate=False;";&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;The next step is to add/edit the data flow task. The following is the code to add a Data Flow Task and set its properties:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;TaskHost th = pkg.Executables.Add("DTS.Pipeline") as TaskHost; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;th.Name = "DataFlow"; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;dataFlow = th.InnerObject as MainPipe;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;//set source component&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource = dataFlow.ComponentMetaDataCollection.New();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.ComponentClassID = "DTSAdapter.OLEDBSource";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.Name = "OLEDBSource";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;CManagedComponentWrapper instanceSource = oledbSource.Instantiate();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.RuntimeConnectionCollection.New();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.RuntimeConnectionCollection[0].ConnectionManagerID = pkg.Connections["OLEDBConnection"].ID;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(pkg.Connections["OLEDBConnection"]);&lt;br /&gt;instanceSource.ProvideComponentProperties(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.SetComponentProperty("OpenRowset", "Emp");&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.SetComponentProperty("AccessMode", 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;br /&gt;// Acquire Connections and reinitialize the component&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.AcquireConnections(null);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.ReinitializeMetaData();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.ReleaseConnections();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;In case you already have a template with the data flow task, we can get the handle of it using the &lt;strong&gt;Executable&lt;/strong&gt; collection. The following is the code for modifying a DataFlow task:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;Executable exe = x.Executables["Data Flow Task"]; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;TaskHost th2 = exe as TaskHost; d&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;ataFlow = th2.InnerObject as MainPipe; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;IDTSComponentMetaDataCollection90 metadataCollection = dataFlow.ComponentMetaDataCollection;&lt;br /&gt;//set source component &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource = dataFlow.ComponentMetaDataCollection[0]; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;if (oledbSource.RuntimeConnectionCollection.Count &gt; 0) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(x.Connections["OLEDBConnection"]); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbSource.RuntimeConnectionCollection[0].ConnectionManagerID = x.Connections["OLEDBConnection"].ID; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;CManagedComponentWrapper instanceSource = oledbSource.Instantiate(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.SetComponentProperty("OpenRowset", "Temp_1"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.SetComponentProperty("AccessMode", 0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;// Acquire Connections and reinitialize the component &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.AcquireConnections(null); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.ReinitializeMetaData(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceSource.ReleaseConnections();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;The same steps are followed for setting the properties of the destination component. The following is the code for modifying the connection properties of OLEDB Destination component:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;//set destination component &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbDestination = dataFlow.ComponentMetaDataCollection[1]; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;if (oledbDestination.RuntimeConnectionCollection.Count &gt; 0) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(x.Connections["OLEDBConnection"]); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;oledbDestination.RuntimeConnectionCollection[0].ConnectionManagerID = x.Connections["OLEDBConnection"].ID; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;}&lt;br /&gt;CManagedComponentWrapper instanceDest = oledbDestination.Instantiate();&lt;br /&gt;instanceDest.SetComponentProperty("OpenRowset", "Temp_2"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceDest.SetComponentProperty("AccessMode", 0);&lt;br /&gt;// Acquire Connections and reinitialize the component &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceDest.AcquireConnections(null);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceDest.ReinitializeMetaData(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;instanceDest.ReleaseConnections();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;The next step is to "Map" the columns of the source and destination components. The following is the code to map the input column collection (source collection) to the External Metadata column collection (Destination collection):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;IDTSInput90 input = oledbDestination.InputCollection[0];&lt;br /&gt;IDTSVirtualInput90 vInput = input.GetVirtualInput();&lt;br /&gt;foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)&lt;br /&gt;{&lt;br /&gt;IDTSInputColumn90 vCol = instanceDest.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);&lt;br /&gt;instanceDest.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;br /&gt;Finally we save the package to the file system.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;string currentDirectory = System.IO.Directory.GetCurrentDirectory();&lt;br /&gt;a.SaveToXml(currentDirectory + "\\DTSDataflow.dtsx", pkg, null);&lt;br /&gt;Console.WriteLine("Successfully created an SSIS package");&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;Console.ReadLine();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In case you want to save the package directly to Yukon server, you can use the following code:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;a.SaveToSqlServer(pkg, null, "mdpkb2e139", "", "");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here it goes! You have now programmatically created a simple SSIS package.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111805414834922306?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111805414834922306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111805414834922306&amp;isPopup=true' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111805414834922306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111805414834922306'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/05/how-to-programmatically-create-ssis.html' title='HOW TO: Programmatically create SSIS packages using Whidbey'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111467118052200786</id><published>2005-04-27T23:41:00.000-07:00</published><updated>2006-07-11T08:16:05.263-07:00</updated><title type='text'>SSIS in Yukon - Part II - Creating a Simple Package in SSIS</title><content type='html'>In the previous article we had discussed about the new IDE for SSIS.&lt;br /&gt;Now let us see how to create a simple SSIS package. The following are the steps:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;From the &lt;strong&gt;File&lt;/strong&gt; menu, click &lt;strong&gt;New&lt;/strong&gt;-&gt; &lt;strong&gt;Project&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Under &lt;strong&gt;Projects&lt;/strong&gt;, choose &lt;strong&gt;Business Intelligence Projects&lt;/strong&gt; and under &lt;strong&gt;Templates&lt;/strong&gt;, choose &lt;strong&gt;Integration Service Project,&lt;/strong&gt; and then click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;By default a package named &lt;strong&gt;Package.dtsx&lt;/strong&gt; is created under the folder &lt;strong&gt;SSIS Packages&lt;/strong&gt;. Click&lt;strong&gt; View-&gt; Solution Explorer&lt;/strong&gt; to see this.&lt;/li&gt;&lt;li&gt;Right click on the &lt;strong&gt;Connections&lt;/strong&gt; pane, and then click&lt;strong&gt; New OLE-DB Connection&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Create two new connections - one to your Yukon source server and another to your Yukon destination server. Name these connections as &lt;strong&gt;MySourceConnection &lt;/strong&gt;and &lt;strong&gt;MyDestinationConnection&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;From the &lt;strong&gt;View&lt;/strong&gt; menu, click &lt;strong&gt;Toolbox&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Now drag and drop a &lt;strong&gt;Data Flow Task&lt;/strong&gt; component on the Control Flow pane.&lt;/li&gt;&lt;li&gt;Double-click the Data Flow Task component to take you to the Data Flow pane.&lt;/li&gt;&lt;li&gt;From the toolbox, drag and drop a &lt;strong&gt;OLE DB Source&lt;/strong&gt; component and &lt;strong&gt;OLE DB Destination&lt;/strong&gt; component. Name them as &lt;strong&gt;MySource&lt;/strong&gt; and &lt;strong&gt;MyDestination&lt;/strong&gt; respectively.&lt;/li&gt;&lt;li&gt;Double-click &lt;strong&gt;MySource&lt;/strong&gt;. &lt;/li&gt;&lt;li&gt;Set the connection of &lt;strong&gt;MySource&lt;/strong&gt; to &lt;strong&gt;MySourceConnection.&lt;/strong&gt;&lt;/li&gt;&lt;li&gt;Set the &lt;strong&gt;Data-access mode&lt;/strong&gt; to &lt;strong&gt;Table or View&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Set the name of the Source table from the listed tables of the database.&lt;/li&gt;&lt;li&gt;By clicking on the &lt;strong&gt;Columns &lt;/strong&gt;tab on the left, you will be able to see the list of columns for the table. You can uncheck the columns that are not needed and then click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Set the properties of MyDestination OLEDB component in the same way as in 14.&lt;/li&gt;&lt;li&gt;Click on MySource component. Drag the Green arrow you notice and make it point to &lt;strong&gt;MyDestination&lt;/strong&gt; component. You have now connected the Source and the Destination components.&lt;/li&gt;&lt;li&gt;From the &lt;strong&gt;Debug &lt;/strong&gt;menu click &lt;strong&gt;Start&lt;/strong&gt; to run your first SSIS project.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Once your package has executed successfully, you will see components (Dataflow task, MySource and MyDestination) coloured in &lt;span style="color:#009900;"&gt;&lt;strong&gt;Green&lt;/strong&gt;&lt;/span&gt;.&lt;span style="color:#000000;"&gt;&lt;strong&gt; &lt;/strong&gt;And if there is any failure during execution, the components are coloured in &lt;strong&gt;&lt;span style="color:#ff6666;"&gt;Red&lt;/span&gt;&lt;/strong&gt;.&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;strong&gt; &lt;/strong&gt;The success or failure of the package can be monitored by clicking on the &lt;strong&gt;Progress&lt;/strong&gt; tab in the project during execution. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The Source and Destination components must contain the same number of columns and same column names (case sensitive) to avoid Validation errors.&lt;/p&gt;&lt;p&gt;You can also have Event Handlers at the Package level or for each component in the &lt;strong&gt;Event Handler&lt;/strong&gt; tab.&lt;/p&gt;&lt;p&gt;So this is how we go about creating a simple package. My next article will focus on how you can programmatically create these SSIS packages using Whidbey.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111467118052200786?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111467118052200786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111467118052200786&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111467118052200786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111467118052200786'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/04/ssis-in-yukon-part-ii-creating-simple.html' title='SSIS in Yukon - Part II - Creating a Simple Package in SSIS'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111459234739573424</id><published>2005-04-27T01:55:00.000-07:00</published><updated>2005-04-27T03:31:47.250-07:00</updated><title type='text'>SQL Server Integration Services (SSIS) in Yukon</title><content type='html'>Many of us are familiar with Data Transformation Services (DTS) in SQL Server 2000.&lt;br /&gt;&lt;br /&gt;SQL Server 2005 (code named Yukon) provides a completely new platform called SQL Server Integration Services (SSIS) that serves as the primary enterprise platform Extract, Transform and Load (ETL).&lt;br /&gt;&lt;br /&gt;There are a looot of enhancements that has happened to DTS in Sql 2000. Creating packages is now separated to a new Development environment called Business Intelligence Development Studio (bienv.exe). This gives the same look n feel as our Visual Studio Dev Environment.&lt;br /&gt;We have everything similar to VS - the Solution, Project, toolbox, setting configurations, etc.&lt;br /&gt;&lt;br /&gt;The toolbox contains various tasks and componets that can be used in the editor.&lt;br /&gt;&lt;br /&gt;There are 4 tabs provided in the editor:&lt;br /&gt;&lt;br /&gt;1. Control flow - For controlling the task flow&lt;br /&gt;2. Data Flow - For Data pumping tasks&lt;br /&gt;3. Event handlers - For handling events and errors&lt;br /&gt;4. Package Explorer - Gives a treeview view of the various components in the package&lt;br /&gt;5. Execution results - For viewing the status during execution&lt;br /&gt;&lt;br /&gt;The connections form a separate section that is common to the above four tabs. Connection manages for File, SQL Server, OLE DB can be added here.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another cool feature is the Logging feature. All we have to do is just Right click the editor pane and enable Logging with a specific connection. All events now get logged in the specified server.&lt;br /&gt;&lt;br /&gt;Every package that is a part of a SSIS project can be executed from BI. The deployment of these packages can be done either to the file system or to SQL Server. The packages deployed in SQL Server will be saved in the DTS Server.&lt;br /&gt;&lt;br /&gt;My next article will throw more light on working with SSIS and programmability in Whidbey for SSIS.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111459234739573424?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111459234739573424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111459234739573424&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111459234739573424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111459234739573424'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/04/sql-server-integration-services-ssis.html' title='SQL Server Integration Services (SSIS) in Yukon'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12419046.post-111442314010069363</id><published>2005-04-25T02:55:00.000-07:00</published><updated>2005-06-10T02:43:32.173-07:00</updated><title type='text'>HOW TO : Call a C# function inside Yukon Stored Procedure</title><content type='html'>&lt;p&gt;&lt;span style="font-family:georgia;"&gt;Recently I had an interesting requirement in my project to use a C# procedure inside SQL.&lt;br /&gt;Prior to SQL Server 2005, we had to use only Extended store procedures..&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;But as Yukon is integrated with CLR, you can now call a C# Whidbey function inside SQL Server procedure.&lt;br /&gt;&lt;br /&gt;The following is the way you can do it: &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:georgia;"&gt;1. Start Visual Studio 2005.&lt;br /&gt;2. On the &lt;strong&gt;File&lt;/strong&gt; menu, click &lt;strong&gt;New Project&lt;/strong&gt;.&lt;br /&gt;3. Under Projects, choose &lt;strong&gt;Visual C#&lt;/strong&gt; and under Templates choose &lt;strong&gt;SQL Server Project&lt;/strong&gt; template. Click &lt;strong&gt;OK&lt;/strong&gt;. By default a project named SqlServerProject1 is created.&lt;br /&gt;4. You will now be prompted to specify a connection. Provide the connection of the Yukon server for which you need the C# function.&lt;br /&gt;&lt;br /&gt;5. Right click &lt;strong&gt;SqlServerProject1&lt;/strong&gt; on Solution Explorer and click &lt;strong&gt;Add New Item&lt;/strong&gt;. Choose any template that is provided.&lt;br /&gt;6. Now replace the following code with the existing code provided with the template:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="color:#000099;"&gt;#region Using directives&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Data.Sql;&lt;br /&gt;using System.Data.SqlServer;&lt;br /&gt;#endregion&lt;br /&gt;public class MyClass&lt;br /&gt;{&lt;br /&gt;public MyClass()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;public static void GetDepartmentDetailsByNum(int DeptNo)&lt;br /&gt;{&lt;br /&gt;SqlPipe sp = SqlContext.GetPipe();&lt;br /&gt;sp.Send("The Department number is " + DeptNo.ToString() + "\n");&lt;br /&gt;SqlCommand cmd = SqlContext.GetCommand();&lt;br /&gt;cmd.CommandText = "select * from dept where deptnum=" + DeptNo.ToString();&lt;br /&gt;SqlDataReader rdr = cmd.ExecuteReader();&lt;br /&gt;sp.Send(rdr);&lt;br /&gt;}&lt;br /&gt;public static void GetSum(int x, int y)&lt;br /&gt;{&lt;br /&gt;SqlPipe sp = SqlContext.GetPipe();&lt;br /&gt;int z=x+y;&lt;br /&gt;sp.Send(z.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;7. Now save the project and Build the project.&lt;br /&gt;8. Open SQL Server Management Studio and connect to the Yukon server.&lt;br /&gt;9. Right click the Database where the C# function is needed and then click &lt;strong&gt;New Query&lt;/strong&gt;.&lt;br /&gt;10. In the query editor, paste the following code:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;color:#333399;"&gt;CREATE ASSEMBLY ManagedCsharpProcedure&lt;br /&gt;FROM 'C:\Laksk\SqlServerProject1\bin\Debug\SqlServerProject1.dll' &lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:georgia;color:#333399;"&gt;CREATE PROCEDURE [dbo].[GetSum]&lt;br /&gt;@x int ,@y int&lt;br /&gt;AS&lt;br /&gt;EXTERNAL NAME&lt;br /&gt;SqlManaged.DeptDetails.GetSum&lt;br /&gt;GO&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:georgia;"&gt;&lt;p&gt;11. Now test the GetSum procedure using the following statement :&lt;br /&gt;exec GetSum 5,4&lt;br /&gt;&lt;br /&gt;Thats it !!! You now have a C# method being called in SQL Server. The same method can also be used with recordsets as in the C# function &lt;strong&gt;GetDepartmentDetailsByNum &lt;/strong&gt;that is included in the same class. So on passing the Dept Number, we get the Department details through the C# function.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12419046-111442314010069363?l=lakshmik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lakshmik.blogspot.com/feeds/111442314010069363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12419046&amp;postID=111442314010069363&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111442314010069363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12419046/posts/default/111442314010069363'/><link rel='alternate' type='text/html' href='http://lakshmik.blogspot.com/2005/04/how-to-call-c-function-inside-yukon.html' title='HOW TO : Call a C# function inside Yukon Stored Procedure'/><author><name>Lakshmi</name><uri>http://www.blogger.com/profile/05033914754047255171</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry></feed>
