<?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-2557049885090666521</id><updated>2012-02-17T10:29:49.240+05:30</updated><title type='text'>Faqs on asp.net,c#,vb.net and sqlserver2005</title><subtitle type='html'>this blog covers all the Faqs related to .net technologies like asp.net,vb.net,c#.net,ajax,javascript and sqlserver2005.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>.NET team</name><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>64</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-3810233424772507106</id><published>2008-04-02T15:00:00.000+05:30</published><updated>2008-04-02T15:03:32.255+05:30</updated><title type='text'>Windows Drive not opening directly</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Sometimes it happens in windows XP that you are not able to open drives on your hard disk. When you double clicking on the drives icons or right click on the drive&gt;&gt;explore in My computer ,the drive does not open.&lt;br /&gt;&lt;br /&gt;This problem is generally caused by most of the viruses which infect windows XP system. They block or restrict your access to any of the drives.&lt;br /&gt;&lt;br /&gt;But don’t worry this is not a big trouble it can be fixed easily.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Fix:&lt;br /&gt;&lt;br /&gt;Normally when a virus infects a windows system which causes a drive opening problem, it automatically creates a file named autorun.inf in the root directory of each drive.&lt;br /&gt;&lt;br /&gt;This autorun.inf file is a read only ,hidden and a system file and the folder option is also disabled by the virus. This is deliberately done by the virus in order to protect itself. autorun.inf initiates all the activities that the virus performs when you try to open any drive.&lt;br /&gt;&lt;br /&gt;You have to just delete this file and restart your system to correct this problem.&lt;br /&gt;&lt;br /&gt;Follow the set of commands below to show and delete the autorun.inf&lt;br /&gt;&lt;br /&gt;1. Open Start&gt;&gt;Run and type cmd and press enter. This will open a command prompt window. On this command prompt window type the following steps.&lt;br /&gt;&lt;br /&gt;2. type cd\&lt;br /&gt;&lt;br /&gt;3. type attrib -r -h -s autorun.inf&lt;br /&gt;&lt;br /&gt;4. type del autorun.inf&lt;br /&gt;&lt;br /&gt;5. now type d: and press enter for d: drive partition. Now repeat steps 3 and 4. Similarly repeat step 5 for all your hard disk partition.&lt;br /&gt;&lt;br /&gt;Restart your system and your trouble will be fixed. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-3810233424772507106?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/3810233424772507106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=3810233424772507106' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3810233424772507106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3810233424772507106'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/04/windows-drive-not-opening-directly.html' title='Windows Drive not opening directly'/><author><name>.NET team</name><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-2557049885090666521.post-5329118891746203240</id><published>2008-03-17T16:41:00.002+05:30</published><updated>2008-03-17T16:53:24.689+05:30</updated><title type='text'>Validating Images before Upload by Checking the File Stream</title><content type='html'>&lt;a href="http://newcsharp.blogspot.com/"&gt;&lt;span style="font-family:verdana;"&gt;Validating Images before Upload by Checking the File Stream&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Rather than just checking for valid file extensions, there are more advanced ways of checking that your users are not uploading rubbish to your image file store (we currently use MOSS for storage at Lend Lease).&lt;br /&gt;///summary&lt;br /&gt;&lt;summary&gt;/// Added to validate that an image is being uploaded - not just any document &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;/// summary &lt;param name="data"&gt;&lt;/param&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; &lt;returns&gt;&lt;/returns&gt;private bool IsImage(byte[] data)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; //read 64 bytes of the stream only to determine the type&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; string myStr = System.Text.Encoding.ASCII.GetString(data).Substring(0, 16); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//check if its definately an image. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;if (myStr.Substring(8, 2).ToString().ToLower() != "if")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; { &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//its not a jpeg&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; if (myStr.Substring(0, 3).ToString().ToLower() != "gif") &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//its not a gif&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; if (myStr.Substring(0, 2).ToString().ToLower() != "bm") &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; //its not a .bmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; if (myStr.Substring(0, 2).ToString().ToLower() != "ii")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; { &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//its not a tiff&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; //ProcessErrors("notImage"); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;myStr = null; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; } &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;myStr = null; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;return true; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; public Response&lt;list&gt;&lt;sharepointdocumentdto&gt;&gt; AddAssetImageToSession( string fileName, Stream contentStream, IWebPageView currentView, string parentWindow) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Response response = GetAssetImageSingle();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; if (string.IsNullOrEmpty(fileName)) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;response.Errors.Add(new Error(ErrorName.FileError, Errors.MissingFileName)); response.IsSuccessful = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; } &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;else &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SharepointDocumentDto item = new SharepointDocumentDto();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; item.Name = fileName;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; //Set FileName item.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;IsNewItem = true; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//Flag as true so we know to save it when the asset is saved item.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;GeneratedListItemId = Guid.NewGuid().ToString();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; MemoryStream ms = new MemoryStream(); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;byte[] data = new byte[256];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; int c = contentStream.Read(data, 0, data.Length);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; //Check if it is a valid image&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; if (!IsImage(data)) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; response.Errors.Add(new Error(ErrorName.FileError, Errors.InvalidImageUploaded)); response.IsSuccessful = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; return response; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//invalid&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;//Read into buffer until end of file&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; while (c &gt; 0)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Reference:&lt;/span&gt;&lt;a href="http://ddkonline.blogspot.com/2008/03/checking-for-valid-images-by-checking.html"&gt;&lt;span style="font-family:verdana;"&gt;http://ddkonline.blogspot.com/2008/03/checking-for-valid-images-by-checking.html&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5329118891746203240?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5329118891746203240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5329118891746203240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5329118891746203240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5329118891746203240'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/validating-images-before-upload-by.html' title='Validating Images before Upload by Checking the File Stream'/><author><name>.NET team</name><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-2557049885090666521.post-59824612108027633</id><published>2008-03-17T16:27:00.002+05:30</published><updated>2008-03-17T16:31:42.572+05:30</updated><title type='text'>Latest Developments in the .Net World</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Do you want to know about the latest development in the .Net technology? Here is a comprehensive look at the latest developments in the world of Microsoft’s.NET.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;If you are committed software developer, you must be aware that ‘web services’ is the latest buzzword to have hit the IT industry. And that this technology trend holds tremendous potential for addressing business problems.&lt;br /&gt;Extensible markup language (XML) is the universal format for data on the web. With XML web services gaining momentum among developers as the next generation of internet-based computing. A platform that made it similar to build these solutions and provide a reliable framework for integration and interoperability was needed. Microsoft’s answer to this much-felt need was .NET—a platform for building, deploying, operating and integrating XML web services.&lt;br /&gt;.NET is the only platform that has been built to support XML services ground up, and Microsoft has been extensively working with the industry to develop standard s like SOAP and UDDI, the XML web services search directory that exits today.&lt;br /&gt;Let’s now take a detailed look at all that Microsoft’s .NET has to offer software developers by the analyzing the latest developments that have taken place in this platform.&lt;br /&gt;&lt;strong&gt;ASP.NET&lt;br /&gt;&lt;/strong&gt;ASP.NET is more than the next version of active server pages (APS) ----- it is the unified web development platform that provides the services necessary for developers to build enterprise-class web applications.ASP.NET is a compiled, .NET –based environment; you can author applications in any.NET compatible language, including ASP.NET Visual Basic .NET,C#, and the jscript.NET.Additionally, the entire .NET framework is available to any ASP.NET application.&lt;br /&gt;Developers can choose from one of two features when creating an ASP.NET application, web services, or combine these in any way they see fit.&lt;br /&gt;Web forms to allow you to build powerful forms-based web pages. When building these pages, you can use ASP.NET server controls to create common UI elements, and programs then from common tasks.&lt;br /&gt;These controls to allow you to rapidly build a web form out of reusable built-in or custom components, simplifying the code of a page.&lt;br /&gt;An XML web service provides the means to access server functionality remotely. Using web services, interfaces to their data or business logic, which is turn can be obtained and manipulated by client and server applications. XML web services enable the exchange of data in client-server or server- server scenarios, using standards like HTTP and XML messaging to move data across firewalls.&lt;br /&gt;Each of these models can take full advantage of all ASP.NET framework and.NET framework common language runtime. These features and how you can use them are outlined as follow:&lt;br /&gt;If you have ASP development skills, the new ASP.NET programming model will seem very familiar to you. However, the ASP.NET object model has changed significantly from ASP, making it move structured and object oriented.&lt;br /&gt;Accessing database from ASP.NET application is an often-used technique for displaying data to website visitors. ASP.NET makes it easier then ever to access database for this purpose.&lt;br /&gt;ASP.NET provides a simple model that enables developers to write logic that runs at the application level. Developers can   write this code in the global. Asax text files or in a compiled class deployed as an assembly.&lt;br /&gt;ASP.NET provides easy-to-use application and session-state-facilities that are familiar to ASP developers and readily compatible with all other .NET framework APIs.&lt;br /&gt;For advanced developers who wants to use APIs as powerful as the ISPI programming interfaces that were included with previous version of ASP, ASP.NET  offer the IHttpHandler interfaces.&lt;br /&gt;ASP.NET takes advantage of performance enhancements found in the .NET framework and common language runtime.&lt;br /&gt;The. NET framework and ASP.NET provide default authorization and authentication schemes for web application.&lt;br /&gt;ASP.NET configuration setting are stored in XML-based files , which are human readable and writable.&lt;br /&gt;&lt;strong&gt;VB.NET&lt;br /&gt;&lt;/strong&gt;Visual basic .NET enable you to create rich application for Microsoft Windows in less time, incorporate data access from a wider range of database scenarios, create components with minimal code, and build web-based application using your exiting skills. Builds powerful windows-based applications in less time and more robust windows-based applications with less code.&lt;br /&gt;1. Web-based applications&lt;br /&gt;Helps to create web solutions in visual basic.NET using the shared web forms designer and HTML designer&lt;br /&gt;2. Flexible, simplified data access&lt;br /&gt;Offers support to tackle any data access scenario easily with Microsoft ADO.NET and Microsoft Active X Data objects (ADO) data access. &lt;br /&gt;3. Improved coding&lt;br /&gt;It brings a multitude of enhancements to the code editor, including enhanced intellisence , smart listing of code for greater readability , squiggles , and a background compiler for realtime notification of syntax .&lt;br /&gt;4. Direct access to the platform&lt;br /&gt;Features quick leverage of registry , eventlog , performance counters , and file system in user’ application and eliminates the need to use declared statements .&lt;br /&gt;5. Full object-oriented constructs&lt;br /&gt;Helps create reusable, enterprise-class code using full object-oriented constructs .Language features include full implementation inheritance, encapsulation ,and polymorphism .&lt;br /&gt;6. XML Web services&lt;br /&gt;The new XML .Web services project templates builds all underlying Web services enable you to call components running on any platform.&lt;br /&gt;7. Mobile applications&lt;br /&gt;These new features give developers a single, mobile Web interface to support a broad range of Web devices, including WWL 1.1 for WAP-enabled cellular phones , compact HTML (cHTML) for i-mode phones ,and HTML for pocket PC handheld devices , and pagers . Reach out to more than 80 different Internet-enabled mobile devices using the Microsoft mobile Internet Toolkit .&lt;br /&gt;8. Com interoperability&lt;br /&gt;This feature enables seamless bi-directional communication between Visual Basic 6.0 and Visual Basic Net applications.&lt;br /&gt;&lt;strong&gt;VS .NET&lt;br /&gt;&lt;/strong&gt;Visual Studio .NET is the comprehensive tool for rapidly building and inter grating XML. Web services and application dramatically increasing developer productivity, and enabling new business opportunities.&lt;br /&gt;1. Enterprise Architect&lt;br /&gt;Visually specify and communicate application architecture: It uses Microsoft Visio-based Modeling Language (UML) modeling to specify and communicate application architecture and functionality.&lt;br /&gt;Gain unparalleled support for database modeling: Full roundtrip engineering, with logical and physical data models, enables communication from the business analyst to the database designer.&lt;br /&gt;Easily shared best practices: Senior developers and architects can customize enterprise template projects to provide application starting points and guidance for less experienced developers.&lt;br /&gt;Use the industry-leading development environment: Leverage the powerful capabilities in Visual Studio.Net for rapidly building XML web services and applications that span devices and platforms.&lt;br /&gt;Define and communicate development policies: developers can immediately view any policy violations and discrepancies in their code in the task list window.&lt;br /&gt;&lt;strong&gt;Enterprise Developers:&lt;/strong&gt;&lt;br /&gt;Fast and easy test of XML web services and applications: VS.Net can quickly create and run tests within the visual studio.Net environment to fine-tune the performance of XML web services and applications and verify functionality.&lt;br /&gt;Maximize developer productivity: It leverages the powerful capabilities in Visual Studio .Net for rapidly building XML web services and applications that span devices and platforms.&lt;br /&gt;&lt;strong&gt;Simplify server-side development:&lt;/strong&gt;  This feature helps to visually build server-side components with the server explorer and Visual component Designer.&lt;br /&gt;Build, leverage, and extend scalable XML web services: it creates components that can be accessed on any platform by using XML web services easily publish and component as XML web services, and reuse existing XML web services running on any platform.&lt;br /&gt;&lt;strong&gt;Get support for the complete lifecycle:&lt;/strong&gt; The Visual Studio integration technologies bring a broad array of partners of visual studio .Net developers and enables third party languages, components and tools to integrate tightly with visual studio .Net through various stages of the development in lifecycle.VS .NET Professional :&lt;br /&gt;&lt;strong&gt;XML web services :&lt;/strong&gt; It helps to create components that can be accessed on any platform by using XML web services . Converts existing functions to XML web services and reuses existing XML web services.&lt;br /&gt;High-performance database application with XML : It uses the built-in Microsoft ADO.NET tools to build database applications with Microsoft SQL Server , Oracle ,or any other XML-based data source .&lt;br /&gt;Supports Rapid Application Devlopment (RAD) for the server developed for thin-&lt;strong&gt;client devices :&lt;/strong&gt; Offers developers a single mobile web interface to support a broad range of web devices –including WML .1.1 for WAP cell phones , compact HTML(cHTML)  for i-mode , and HTML, for pocket PC, palm-size PCs pagers .&lt;br /&gt;&lt;strong&gt;Shared IDE :&lt;/strong&gt; It uses a single unified integrated development environment (IDE) for all languages with a single toolbox debugger and task window across Visual Basic ,C++ and C# project .    &lt;br /&gt;&lt;strong&gt;Windows CE .NET&lt;br /&gt;&lt;/strong&gt;Window CE .NET is the successor to Windows CE 3.0 Designed from the ground up for the embedded marketplace , Window CE .NET aims to deliver a robust realtime operating  system for rapidly building the next generation of smart mobile and small footprint devices. With a complete operating system feature set and end-to-end development environment Windows CE-based devices that requires rich networking hard real time, and a small footprint , as well as rich multimedia and Web browsing capabilities. Windows CE .NET offers.&lt;br /&gt;Scalable  wireless technologies : Windows CE.NET include scalable wireless technologies that enable mobile devices to flexibly connect into existing infrastructures . Supported wireless technologies include.&lt;br /&gt;&lt;strong&gt;Bluetooth :&lt;/strong&gt;  Windows CE .NET allows a devices to use a Bluetooth-enabled cellular phone as a data modem , and to use a Bluetooth-enabled local area network (LAN) access point to provide network connectivity.&lt;br /&gt;802.1x/Zero Configuration – New features in window CE .NET i.e., 802.11 zero configuration, aim to simplify setup of 802.11 network and to enable seamless roaming from one 802.11 network to another. 801.1x and EAP enhance the security of 802.11 by enabling user/password, certificate, or original equipment manufacturer (OEM) specific authentication to log on to the network.&lt;br /&gt;Object Exchange  (OBEX)  protocol – Windows CE .Net’s support for OBEX works over Bluetooth and infra red data association (IrDA) protocols . Object Exchange (OBEX) is an efficient, compact binary protocol that enables a wide range of devices to exchange data spontaneously in a simple, efficient manner.&lt;br /&gt;Media Sense – This feature improves the roaming experience for mobile devices users by notifying application of network status.&lt;br /&gt;Real time collaboration and communication (RTC/SIP) – Real time communication (RTC) enables messaging, presence, and audio (voice over IP between any two IP-enabled devices.&lt;br /&gt;Realiable core operating system services for demanding embedded designs : Windows CE .ET offers reliable core operating system services that enable the most demanding real time embedded designs across a breadth of devices . New and enhanced operating system features include.&lt;br /&gt;&lt;strong&gt;Small footprint:&lt;/strong&gt; Continuing the effort to minimize the operating system footprint for embedded devices, Windows CE .NET provides granular Kernel componentization. Windows CE .NET supports a minimum configuration platform as small as 200 KB with minimum Kernel functions only.&lt;br /&gt;Enterprise-scale – Network security enhancements include support for the Kerberos Security Protocol.&lt;br /&gt;Wide selection of CPUs- Windows CE .NET provides a high level of processor flexibility with support for the following four families of microprocessors and emulation technologies like ARM, MIPS, SHx, x 86 etc.&lt;br /&gt;Real time – Real time processing support for the most demanding support for the most demanding deterministic applications with 256 priority levels and nested interrupt support.&lt;br /&gt;Net- enabled for creating rich personalized experiences - Windows CE .NET enables you to build smart Microsoft .NET-enabled devices and create rich, personalized experiences.&lt;br /&gt;XML – XML allows developers to easily describe and deliver rich, structured data from any application in a standard consistent way.&lt;br /&gt;Net compact Framework : The .NET Compact Framework supports all processors supported by windows CE .NET . For more information on how to develop application using the .NET Framework, please see .NET on the MSDN site. Look in the .NET Compact Framework Read me’ for specific information about implementation issues in your embedded design.&lt;br /&gt;Microsoft Direct3D API – Provides support for interactive three-dimensional   (3-D) graphics applications by allowing device dependent access to 30d video-display hardware in devices-independent manner.&lt;br /&gt;Windows Media 8 compressor/decompressor (codecs) and controls – Supports the latest Microsoft Windows Media 8 codes and controls ,which allows for the latest high-bandwidth encoded multimedia streams.&lt;br /&gt;&lt;strong&gt;Easy-to-use end-to-end tool set:&lt;/strong&gt;  Windows CE .NET provides an integrated end-to-end tool set to help developers reduce both operating system and application development time, allowing them to get devices to market faster. These tools include.&lt;br /&gt;Emulation technology - Windows CE .NET include emulation technology to enable developers to build and test their designs on their Windows 2000 or Windows xp professional workstations without additional hardware investments.&lt;br /&gt;The new platform wizard – The new platform wizard provides a foundation for startingDevice designs for:&lt;br /&gt;Cellophanes / Smart phones&lt;br /&gt;Custom devices&lt;br /&gt;Digital imaging devices&lt;br /&gt;Industrial automation devices&lt;br /&gt;Internet/media appliances&lt;br /&gt;Personal digital assistants (PDA)/Mobile handhelds&lt;br /&gt;Residential gateways&lt;br /&gt;Retail point-of-sale&lt;br /&gt;Set-top boxes&lt;br /&gt;Tiny kernels&lt;br /&gt;Web pads Windows thin clients.&lt;br /&gt;CE .Net also provides support for managed and native code – To write applications for Windows CE .NET, Microsoft offers a rich set of languages for creating managed .NET-enabled or unmanaged (native) applications.&lt;br /&gt;&lt;strong&gt;NET Compact Framework&lt;/strong&gt; &lt;br /&gt;Microsoft Corp. Has recently released the beta of the Microsoft .NET Compact Framework, extending the .NET strategy to smart handheld devices. The .NET Compact Framework is Microsoft’s mobile application platform technology that harnesses the power of XML Web services on mobile devices. As a subset of the .NET Framework, the .NET Compact Framework shares same programming model and application development tools, enabling .NET developers to transfer their existing skills to build mobile applications, which is expected to accelerate adoption of mobile solutions. It provides key features for smart devices such as a programming model unified with the .Net framework on desktop and server, integral XML web services support, enterprise-class data access using ADO.Net and XML, and rich class libraries that enable developers to build powerful applications in minimal time. Runtime features such as managed code and just-in-time compilation help ensure reliable, high performance applications for a better user experience.The .Net compact framework is complemented by other technologies such as Microsoft SQL server 2000, windows CE edition version 2.0 and the Microsoft mobile internet toolkit (MMIT), SQL server CE is the compact, relational database for rapidly developing applications that extend enterprise data management capabilities to new smart devices. The SQL server CE is the only mobile database that integrates with the .Net compact framework, allowing data to be locally and securely stored and extracted to interact with back-end applications or web services. The Microsoft mobile internet toolkit offers a wide reach to project applications to any kind of mobile device with a browser. The development experience for these technologies is unified through Microsoft Visual Studio &gt;net, which provides a consistent set of tools and interfaces for building applications using Microsoft’s mobile technologies.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-59824612108027633?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/59824612108027633/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=59824612108027633' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/59824612108027633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/59824612108027633'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/latest-developments-in-net-world.html' title='Latest Developments in the .Net World'/><author><name>.NET team</name><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-2557049885090666521.post-3331203038887059196</id><published>2008-03-14T15:36:00.002+05:30</published><updated>2008-03-14T15:39:26.198+05:30</updated><title type='text'>Web Farming with the Network Load Balancing Service in Windows Server 2003</title><content type='html'>&lt;span style="font-family:verdana;"&gt;When a single Web Server machine isn’t enough to handle the traffic on your Web site it’s time to look into building a Web Farm that uses multiple machines on the network acting as a single server. In this article Rick looks at the Windows Load Balancing Service and the new interface it sports in Windows Server 2003, which makes creating a Web Farm quick and easy and – gasp –even an affordable solution.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;With the release of Windows Server 2003 Network Load Balancing has become a much more visible tool as a part of the operating system, providing a very usable and relatively easy to configure interface that makes it easy to build a Web Farm. The Network Load Balancing Service has been around in one incarnation or another since Windows NT SP4, but Windows Server 2003 is the first operating system that brings this service into the forefront as a main component of the OS. A new Network Load Balancing Manager application is now directly available from the Adminstrative Tasks menu and it’s powerful enough to allow to configure the entire cluster from a single console. The service is now available for all products in the Windows Server family including the lower end Web Edition which means that you now have a much more affordable solution to create Web Farms at your disposal. Just add servers please.&lt;br /&gt;&lt;br /&gt;In this article I’ll review the basics of a Load Balancing service and then show you how to set up configure a basic installation using two machines.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Web Farms for city folk – do you need it?&lt;br /&gt;&lt;/strong&gt;A Web Farm is a not so fancy term for a collection of servers that act as a single Web server. The process behind the scenes maps a ‘virtual’ IP address to multiple machines. Software such as the Network Load Balancing Service or hardware like a specialized router or Load Balancer then deals with dishing up requests to the appropriate machine in the server pool.&lt;br /&gt;Web Farms are an obvious choice if you’ve hit the limits of your single machine hardware. But before jumping on the Web Farm band wagon (or is that a tractor?) you should look closely at your hardware and application and be sure that you can’t make it all run on a single machine first. Although the process of creating a Web Farm isn’t difficult, administration of two or more servers and keeping them properly synched is actually a lot more work than administering a single server.&lt;br /&gt;&lt;br /&gt;Upgrading your hardware is certainly one option available to you. Today’s hardware is incredibly capable and should be sufficient to handle all but the most demanding Web applications on a single box. Multiprocessor machines with up to 16 processors on Windows make a pretty powerful platform to run Web applications with, even if those high end machines are rather pricey. While the Yahoo’s and Amazon’s won’t run on a single box (or on Windows for that matter), a vast majority of applications are likely to be able to comfortably serve millions of transactional hits a day from a single machine even with a single processor.&lt;br /&gt;&lt;br /&gt;But Load Balancing can also provide benefits in the overload scenario. For one, it’s generally cheaper to throw mid-level machines at a load problem rather than buying one top of the line high end machine. Even with server licenses involved multiple low end machines might provide a more cost efficient solution.&lt;br /&gt;&lt;br /&gt;Load Balancing also provides something else that has nothing to do with scalability: The ability to have failover support if something goes wrong on one of the servers in the pool. Because a Web Farm are made up of essentially identically configured servers, a failure on a single server will not bring down the entire Web site. Other servers in the pool can continue to process requests and pick up the slack. For many companies this feature of load balancing is often important for peace of mind both in the knowledge that a single point of failure on the Web Server is avoided as well as providing an in place mechanism to grow the application should the need arise at a later point.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.west-wind.com/presentations/loadbalancing/NetworkLoadBalancingWindows2003.asp"&gt;&lt;span style="font-family:verdana;"&gt;http://www.west-wind.com/presentations/loadbalancing/NetworkLoadBalancingWindows2003.asp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-3331203038887059196?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/3331203038887059196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=3331203038887059196' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3331203038887059196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3331203038887059196'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/web-farming-with-network-load-balancing.html' title='Web Farming with the Network Load Balancing Service in Windows Server 2003'/><author><name>.NET team</name><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-2557049885090666521.post-5994614335292643270</id><published>2008-03-14T14:56:00.003+05:30</published><updated>2008-03-14T15:25:14.775+05:30</updated><title type='text'>ListView and DataPager in ASP.NET 3.5</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;New controls in asp.net 3.5&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;I spent a couple of hours today looking over the ListView and DataPager controls in ASP.NET 3.5. Both controls sound interesting and both provide welcome new features to the ASP.NET control arsenal. Although I'm a little wary of having yet another list control (as if we haven't enough of those already between DataGrid, DataList, Repeater, GridView and now the ListView) the ListView control kind of combines functionality of all of these controls into one. Maybe the most important feature of this control is that like the Repeater control it provides much more control over the rendering process at the cost of more markup code in the page.&lt;br /&gt;The ListView is a sort of hybrid between a DataGrid and Repeater that combines the free form templating of the Repeater with the editing features of the data grid. It looks interesting because it basically allows you much more control over the layout than a DataGrid does while still giving you many of the more advanced features of the data grid. The ListView doesn't support paging natively, so the DataPager serves as an external control to provide paging features. The advantage of a separate control is that it gives you much more control about what the pager looks like and where it can be placed on the page - anywhere basically. The Pager is essentially an extender control that extends the ListView with paging capabilities.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;The ListView Control&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Using the ListView for basic data display is very similar to using a Repeater. You have the ListView control and a set of templates that you can apply which include:&lt;br /&gt;LayoutTemplate&lt;br /&gt;ItemTemplate&lt;br /&gt;AlternatingItemTemplate&lt;br /&gt;SelectedItemTemplate&lt;br /&gt;EmptyItemTemplate&lt;br /&gt;EmptyDataTemplate (?)&lt;br /&gt;ItemSeparatorTemplate&lt;br /&gt;GroupTemplate&lt;br /&gt;GroupSeparatorTemplate&lt;br /&gt;EditItemTemplate&lt;br /&gt;InsertItemTemplate&lt;br /&gt;That's a lot of templates . There are a few new ones here like GroupTemplate and InsertItemTemplate. I haven't figured out how GroupTemplate works, but InsertItemTemplate certainly is a nice addition so you can handle both editing and adding in the same space (previously with a DataGrid you had to insertion externally or insert data manually into a DataTable to display the empty row). &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.west-wind.com/WebLog/posts/127340.aspx"&gt;http://www.west-wind.com/WebLog/posts/127340.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5994614335292643270?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5994614335292643270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5994614335292643270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5994614335292643270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5994614335292643270'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/listview-and-datapager-in-aspnet-35.html' title='ListView and DataPager in ASP.NET 3.5'/><author><name>.NET team</name><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-2557049885090666521.post-1344404569414753688</id><published>2008-03-13T16:04:00.002+05:30</published><updated>2008-03-13T16:11:26.871+05:30</updated><title type='text'>Lambda expressions in C# 3.0</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;1. Introduction&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;It is no secret for anybody that C#, which was initially conceived as a language targeted to subsume such different programming paradigms as procedural (imperative), object-oriented (in line with the standards set by C++ and later Java) and component-based (with two clear referents, Delphi and Visual Basic), has evolved since then in a way that attempts to take into account and integrate into the language the best ideas arisen under another points of view of programming, like dynamic languages (Perl, Python, Ruby), data manipulation languages (SQL, XML) or functional programming (LISP, ML).&lt;br /&gt;Lambda expressions, one of the most important new features to be included in the next 3.0 version of C# [3] and one that offers support needed by the LINQ Project [4], are precisely a feature coming from the world of functional programming. In LISP and its dialects, like Scheme, the lambda construction is a mechanism that allows the programmer to define new functions. For instance, the expression:&lt;br /&gt;(define square (lambda (x) (* x x)))&lt;br /&gt;&lt;br /&gt;defines a variable named square, whose value is a function that produces the square of its argument. One of the most prominent characteristics of functional languages, to which the architects of .NET Framework give great importance [2], is that lambda functions can be treated not only as pieces of code that can be invoked, but also as “common and earthly” values that can be manipulated by other code blocks. Using a term I heard the first time more than 20 years ago from my tutor of then, Dr. Luciano Garcia, lambda functions facilitate metaprogramming – the writing of programs capable of manipulating other programs.&lt;br /&gt;This article describes the implementation of lambda expressions in C# 3.0, concentrating mainly on its exploitation as code blocks; issues related to the representation as data and further programmatic manipulation of lambda expressions will be only introduced for the sake of completeness, and a more in-depth discussion of them will be left for a next installment of this column.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;2. Lambda expressions as code entities&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The natural way of implementing a definition like that of the square lambda function in C# would be through a delegate type and a delegate instance [5]:&lt;br /&gt;delegate T Mapping&lt;t&gt;(T x);&lt;br /&gt;Mapping&lt;int&gt; square = delegate(int x) { return x * x; };&lt;br /&gt;&lt;br /&gt;The first line above defines a generic delegate type named Mapping. From this type model, we will be able to create delegate instances for functions that produce a value of type T from another value of the same type T (that is, functions that map – remember the term, which we will be using more frequently in the near future – a value of type T into another value of the same type).&lt;br /&gt;The second line of code defines an instance of the previous delegate type that “points” to a function that returns the square of an integer number. In this sentence we make use of another feature added to C# in version 2.0, anonymous methods, that allow the in-line specification of the block of code that defines the functionality we wish to associate to the delegate instance. In the original version of C# we would have had to define the function explicitly (besides, the delegate couldn’t have been generic):&lt;br /&gt;static int Square(int x)&lt;br /&gt;{&lt;br /&gt;return x * x;&lt;br /&gt;}&lt;br /&gt;Mapping&lt;int&gt; square2 = Square;&lt;br /&gt;&lt;br /&gt;Although anonymous methods offer a more compact and direct notation, their syntax is still quite verbose and imperative by nature. In particular, when defining an anonymous method it is necessary:&lt;br /&gt;· To explicitly use the keyword delegate.&lt;br /&gt;· To explicitly specify the types of the parameters, without any possibility of compiler inference from the usage context.&lt;br /&gt;· In the relatively frequent case when the body of the function is a simple return sentence followed by an expression that calculates the result (as in the case of our square), the excess in syntax is even more evident.&lt;br /&gt;Lambda expressions can be seen as an extension of anonymous methods that offers a more concise and functional syntax. The syntax of a lambda expression consists of a list of variables-parameters, followed by the implication (function application) sign =&gt;, then followed by the expression or block that implements the desired functionality. For instance, our definition of square could be rewritten using a lambda expression like this:&lt;br /&gt;Mapping&lt;int&gt; square3 = x =&gt; x * x;&lt;br /&gt;&lt;br /&gt;Shorter - impossible, right? This sentence expresses in quite a succinct and natural way that square3 references a function that, given some x, produces x multiplied by itself. In this case, the compiler automatically infers from the context that the type of the parameter and the result should be int. We could have indicated that explicitly:&lt;br /&gt;Mapping&lt;int&gt; square4 = (int x) =&gt; x * x;&lt;br /&gt;&lt;br /&gt;If the type of the parameter is specified, or if the expression has more than one parameter (be their type indicated explicitly or not) parenthesis are mandatory. On the other hand, in the right side of the implication we can place a simple expression, as previously, or a block of sentences of any complexity (as long as it produces a result of the correct type):&lt;br /&gt;Mapping&lt;int&gt; square5 = (int x) =&gt; { return x * x; };&lt;br /&gt;&lt;br /&gt;Until now we have been using our own generic delegate type Mapping&lt;t&gt;, but in practice most of the times we will use the different “overloads” of the predefined generic delegate type Func:&lt;br /&gt;// in System.Query.dll&lt;br /&gt;// namespace System.Query&lt;br /&gt;public delegate T Func&lt;t&gt;();&lt;br /&gt;public delegate T Func&lt;a0,&gt;(A0 a0);&lt;br /&gt;public delegate T Func&lt;a0,&gt;(A0 a0, A1 a1);&lt;br /&gt;public delegate T Func&lt;a0,&gt;(A0 a0, A1 a1, A2 a2);&lt;br /&gt;public delegate T Func&lt;a0,&gt;(A0 a0, A1 a1, A2 a2, A3 a3);&lt;br /&gt;&lt;br /&gt;The Func family of types represents delegate instances that reference functions (with 0, 1, 2 or 3 arguments, respectively) that return T. Using Func, we could define a new version of square like this:&lt;br /&gt;Func&lt;int,&gt; square6 = x =&gt; x * x;&lt;br /&gt;&lt;br /&gt;Below we show some more examples of definition and usage of lambda expressions:&lt;br /&gt;// more examples&lt;br /&gt;static Func&lt;double,&gt; hypotenuse =&lt;br /&gt;(x, y) =&gt; Math.Sqrt(x * x + y * y);&lt;br /&gt;&lt;br /&gt;static Func&lt;int,&gt; divisibleBy =&lt;br /&gt;(int a, int b) =&gt; a % b == 0;&lt;br /&gt;&lt;br /&gt;static Func&lt;int,&gt; isPrime =&lt;br /&gt;x =&gt; {&lt;br /&gt;for (int i = 2; i &lt;= x / 2; i++) if (divisibleBy(x, i)) return false; return true; }; static void Main(string[] args) { int n = 19; if (isPrime(n)) Console.WriteLine(n + " is prime"); Console.ReadLine(); } &lt;strong&gt;&lt;span style="color:#ff6600;"&gt;3. Lambda expressions as data entities&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Considering what we’ve seen until now, anybody could think that lambda expressions are mere “syntactic sugar” added to the language in order to “sweeten” the consumption of delegates and anonymous methods. But C# 3.0 lambda expressions offer an additional possibility not available to anonymous methods, and one that plays a key role in the implementation of the LINQ (Language Integrated Query) technology, that will also be included in the next version of C# and VB and that constitutes, in the humble opinion of this author, one of the most significant advances in programming languages and systems in recent times.&lt;br /&gt;This additional possibility is that of being compiled as expression trees, data objects that efficiently represent in memory the algorithm of evaluation of lambda expressions. These in-memory trees can later be easily manipulated by software (metaprogramming!), stored, transmitted, etc. Although we’ll defer a more detailed analysis of expression trees until our next installment, let’s see a small example:&lt;br /&gt;static Expression func double, hypotenuseExpr =&lt;br /&gt;(x, y) =&gt; Math.Sqrt(x * x + y * y);&lt;br /&gt;&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(hypotenuseExpr);&lt;br /&gt;// prints '(x, y) =&gt; Sqrt(Add(Multiply(x, x), Multiply(y, y)))'&lt;br /&gt;&lt;br /&gt;hypotenuse = hypotenuseExpr.Compile(); // here ILAsm is generated!&lt;br /&gt;Console.WriteLine("Hypotenuse(3, 4) = " + hypotenuse(3, 4));&lt;br /&gt;// prints 'Hypotenuse(3, 4) = 5'&lt;br /&gt;&lt;br /&gt;Console.ReadLine();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;In the code fragment above, the lambda expression that calculates the hypotenuse of a right triangle is assigned not to a delegate, but to a variable of the predefined generic type Expression:&lt;br /&gt;// in System.Query.dll&lt;br /&gt;// namespace System.Expressions&lt;br /&gt;public class Expression&lt;t&gt; : LambdaExpression { … }&lt;br /&gt;&lt;br /&gt;In this case, the compiler does not generate the ILAsm code corresponding to the expression; an object tree that represents the sequence of actions needed for expression’s evaluation is produced instead. You can get an idea of the internal structure of this tree by watching the output produced by the call to its ToString() method.&lt;br /&gt;Note also that the Expression class offers a Compile() method that makes it possible to dynamically generate the executable code corresponding to the expression when needed. That is, this method serves as a “bridge” between both worlds, translating data into code when it becomes necessary to evaluate the expression.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.elguille.info/NET/futuro/firmas_octavio_ExpresionesLambda_EN.htm" target="_blank"&gt;http://www.elguille.info/NET/futuro/firmas_octavio_ExpresionesLambda_EN.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-1344404569414753688?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1344404569414753688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1344404569414753688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1344404569414753688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1344404569414753688'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/lambda-expressions-in-c-30.html' title='Lambda expressions in C# 3.0'/><author><name>.NET team</name><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-2557049885090666521.post-2011575887187396803</id><published>2008-03-13T14:03:00.005+05:30</published><updated>2008-03-13T16:03:56.160+05:30</updated><title type='text'>Lambda Expressions Feature in C# 3.0</title><content type='html'>&lt;span style="font-family:verdana;"&gt;C# 2.0 (released in November 2005) introduced a new feature, anonymous methods, that allows you to declare your method code inline instead of with a delegate function. Lambda expressions, a new feature in C# 3.0, have a more concise syntax to achieve the same goal. Take a closer look at anonymous methods before discussing lambda expressions.&lt;br /&gt;Suppose you want to create a button that updates a ListBox on your form when you click it. In C# 1.0 and 1.1, you would do it as follows:public MyForm()&lt;br /&gt;{&lt;br /&gt;listBox = new ListBox(...);&lt;br /&gt;textBox = new TextBox(...);&lt;br /&gt;addButton = new Button(...);&lt;br /&gt;addButton.Click += new EventHandler(AddClick);&lt;br /&gt;}&lt;br /&gt;void AddClick(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;listBox.Items.Add(textBox.Text);&lt;br /&gt;}&lt;br /&gt;With C# 2.0, you could have it as under:public MyForm()&lt;br /&gt;{&lt;br /&gt;listBox = new ListBox(...);&lt;br /&gt;textBox = new TextBox(...);&lt;br /&gt;addButton = new Button(...);&lt;br /&gt;addButton.Click += delegate&lt;br /&gt;{&lt;br /&gt;listBox.Items.Add(textBox.Text);&lt;br /&gt;};&lt;br /&gt;As you can see, you don't have to explicitly declare a new method to link it with an event. You can use anonymous methods to achieve the same thing in C# 2.0. C# 3.0 introduces an even simpler syntax, lambda expressions, which you write as a parameter list followed by the "=&gt;" token, followed by an expression or a statement block.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Parameters to Lambda Expressions&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The parameters of a lambda expression can be explicitly or implicitly typed. In an explicitly typed parameter list, the type of each expression is explicitly specified. In an implicitly typed parameter list, the types are inferred from the context in which the lambda expression occurs:(int x) =&gt; x + 1 // explicitly typed parameter&lt;br /&gt;(y,z) =&gt; return y * z; // implicitly typed parameter&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Lambda Expressions Demonstration&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The following code snippet from &lt;/span&gt;&lt;a href="http://www.developer.com/img/2006/04/LambdaExample.zip"&gt;&lt;span style="font-family:verdana;"&gt;the downloadable source code&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; uses two techniques to print out strings in a list whose length is even. The first technique, implemented in the function AnonMethod, is through anonymous methods. The second technique, implemented in the function LambdaExample, is through a lambda expression:// Program.cs&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Query;&lt;br /&gt;using System.Xml.XLinq;&lt;br /&gt;using System.Data.DLinq;&lt;br /&gt;namespace LambdaExample&lt;br /&gt;{&lt;br /&gt;public delegate bool KeyValueFilter&lt;k,&gt;(K key, V value);&lt;br /&gt;static class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;List&lt;string&gt; list = new List&lt;string&gt;();&lt;br /&gt;list.Add("AA");&lt;br /&gt;list.Add("ABC");&lt;br /&gt;list.Add("DEFG");&lt;br /&gt;list.Add("XYZ");&lt;br /&gt;Console.WriteLine("Through Anonymous method");&lt;br /&gt;AnonMethod(list);&lt;br /&gt;Console.WriteLine("Through Lambda expression");&lt;br /&gt;LambdaExample(list);&lt;br /&gt;Dictionary&lt;string,&gt; varClothes= new Dictionary&lt;string,int&gt;();&lt;br /&gt;varClothes.Add("Jeans", 20);&lt;br /&gt;varClothes.Add("Shirts", 15);&lt;br /&gt;varClothes.Add("Pajamas", 9);&lt;br /&gt;varClothes.Add("Shoes", 9);&lt;br /&gt;var ClothesListShortage = varClothes.FilterBy((string name,&lt;br /&gt;int count) =&gt; name == "Shoes" &amp;amp;&amp;amp; count &lt;&gt; 0)&lt;br /&gt;Console.WriteLine("We are short of shoes");&lt;br /&gt;Console.ReadLine();&lt;br /&gt;}&lt;br /&gt;static void AnonMethod(List&lt;string&gt; list)&lt;br /&gt;{&lt;br /&gt;List&lt;string&gt; evenNumbers =&lt;br /&gt;list.FindAll(delegate(string i)&lt;br /&gt;{ return (i.Length % 2) == 0; });&lt;br /&gt;foreach (string evenNumber in evenNumbers)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(evenNumber);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;static void LambdaExample(List&lt;string&gt; list)&lt;br /&gt;{&lt;br /&gt;var evenNumbers = list.FindAll(i =&gt;&lt;br /&gt;(i.Length % 2) == 0); // example of single parameter&lt;br /&gt;foreach(string i in evenNumbers)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(i);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public static class Extensions&lt;br /&gt;{&lt;br /&gt;public static Dictionary&lt;k,&gt; FilterBy&lt;k,&gt;&lt;br /&gt;(this Dictionary&lt;k,&gt; items, KeyValueFilter&lt;k,&gt; filter)&lt;br /&gt;{&lt;br /&gt;var result = new Dictionary&lt;k,&gt;();&lt;br /&gt;foreach(KeyValuePair&lt;k,&gt; element in items)&lt;br /&gt;{&lt;br /&gt;if (filter(element.Key, element.Value))&lt;br /&gt;result.Add(element.Key, element.Value);&lt;br /&gt;}&lt;br /&gt;return result;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;full article on Lambda Expressions Feature in C# 3.0 read: &lt;/span&gt;&lt;a href="http://www.developer.com/net/csharp/article.php/3598381" target="_blank"&gt;&lt;span style="font-family:verdana;"&gt;http://www.developer.com/net/csharp/article.php/3598381&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-2011575887187396803?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/2011575887187396803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=2011575887187396803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2011575887187396803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2011575887187396803'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/lambda-expressions-feature-in-c-30.html' title='Lambda Expressions Feature in C# 3.0'/><author><name>.NET team</name><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-2557049885090666521.post-5262125266337214369</id><published>2008-03-13T10:48:00.003+05:30</published><updated>2008-03-13T12:51:06.796+05:30</updated><title type='text'>Using Enterprise Library 1.1 with .NET 2.0</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Enterprise Library problem while using ASP.NET 1.1 webservice in ASP.NET 2.0 webservice.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Introduction&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Microsoft's Enterprise Library stands out as one of those rare collections of code with a truly representative name - an enterprise's library of useful features. Many architects deem them so useful they mandate the library for all of their applications. Unfortunately, there are situations when such decisions can prove painful.&lt;br /&gt;&lt;br /&gt;Troubles encountered when running components using the Enterprise Library 1.1 with the ASP.NET 2.0 Beta releases became one such situation. Suddenly that enterprise library was far from a productivity boon. It did not even work with another version of ASP.NET!&lt;br /&gt;&lt;br /&gt;The culprit turned out to be changes in ASP.NET 2.0 configuration mechanics. This adversely effected how Enterprise Library 1.1 components load. The immense gaggle of information residing within the many XML nodes of the Library's numerous configuration files, such as, dataConfiguration.config and loggingConfiguration.config , could not be either properly read or deserialized without some hack or fix.&lt;br /&gt;&lt;br /&gt;Organizations leveraging Enterprise Library 1.1 bits within their .NET 1.1 components suddenly faced some tough choices. Avoid ASP 2.0? Wait for Enterprise Library 2.0 and port code? Hack Enterprise Library 1.1? Drop the Enterprise Library altogether from their components? None of these options appeal to an enterprise architect.&lt;br /&gt;&lt;br /&gt;This article explores a different solution, based on some code that I've referred to as the Enterprise Library Adapter , which is available as the sample download for this article. One based on adapting how Enterprise Library 1.1 obtains its configuration information and instantiates its different application blocks. As seen in &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Figure-1&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; the use of the Enterprise Library Adapter provides a little assistance via the Library's very own public methods to solve the problem.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;For more details on implementation please read&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;:&lt;a href="http://microsoft.apress.com/feature/80/using-enterprise-library-11-with-net-20"&gt;http://microsoft.apress.com/feature/80/using-enterprise-library-11-with-net-20&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5262125266337214369?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5262125266337214369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5262125266337214369' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5262125266337214369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5262125266337214369'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/using-enterprise-library-11-with-net-20.html' title='Using Enterprise Library 1.1 with .NET 2.0'/><author><name>.NET team</name><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-2557049885090666521.post-8352209055578634932</id><published>2008-03-13T10:00:00.001+05:30</published><updated>2008-03-13T10:24:13.031+05:30</updated><title type='text'>ASP.NET 3.5 controls</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;ASP.NET 3.5 controls&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;In addition to infrastructure improvements to better support IIS7, and in addition to toolset enhancements, web developers get 3 new controls in ASP.NET 3.5 (specifically in System.Web.Extensions.dll and specifically in the System.Web.UI.WebControls namespace): ListView, DataPager, and now in Beta 2 we see for the first time LinqDataSource.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-8352209055578634932?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/8352209055578634932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=8352209055578634932' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8352209055578634932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8352209055578634932'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/aspnet-35-controls.html' title='ASP.NET 3.5 controls'/><author><name>.NET team</name><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-2557049885090666521.post-7623434733372938455</id><published>2008-03-13T09:47:00.003+05:30</published><updated>2008-12-11T19:07:09.028+05:30</updated><title type='text'>Windows Communication Foundation (WCF) in .NET 3.0</title><content type='html'>&lt;div&gt;&lt;span style="font-family:verdana;"&gt;As .NET 2.0 and 3.0 share the same CLR, everything written in .NET 2.0 works in .NET 3.0 which is an important and significant departure from previous versions. In terms of change, for those who love algebra equations the relationship can be summed anecdotally as:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;.NET 3.0 = .NET 2.0 + Windows Communication Foundation + Windows Presentation Foundation + Window CardSpace + Workflow Foundation&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;The .NET Framework 3.0 achieves this objective through four key standards-based pillars corresponding to areas identified and requested by our customers. It also introduced a key new language called XAML. XAML is a declarative XML-based language that defines objects and their properties in XML allowing customers to develop workflows (WF) and immersive user experiences (WPF) declaratively. Let us explore the key pillars of the .NET 3.0 framework in greater detail.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Windows Communication Foundation (WCF)&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;WCF allows you to architect services by offering a standards- based framework and a composable architecture. The three key design philosophies for WCF are interoperability, productivity and service-oriented development.&lt;/span&gt;&lt;/div&gt;&lt;img id="BLOGGER_PHOTO_ID_5177076901425632802" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9isAzRa1iI/AAAAAAAAAbw/FA3cTcXlD98/s400/image2.jpg" border="0" /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;Microsoft provides a number of messaging layer channels and service model layer behaviours that can be added and removed easily. It also allows you to define your own custom instances, for example you can write or buy a custom encoder for ASCII and insert it as a reusable channel in the messaging layer that can be used across various systems. WCF interoperates with existing investments and combines and extends existing Microsoft distributed systems technologies like Enterprise Services, System.Messaging, Microsoft .NET Remoting, ASMX and Web Services Extensions (WSE). This change implies that you can use a single model for different types of application behaviours which significantly reduces the complexity in application development. WCF also offers interoperability with non-Microsoft applications through support of the WS-I basic profile and a number of additional WS-* standards.&lt;br /&gt;Finally in terms of productivity you can get a significant order of magnitude difference in developing secure transactional web services using WCF. Think of WCF as tens of thousands of lines of code that you would need to develop, generate and maintain, but instead are provided now as part of the base framework. WCF offers one of the first core programming frameworks that have been designed from the ground-up for services oriented development.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7623434733372938455?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7623434733372938455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7623434733372938455' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7623434733372938455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7623434733372938455'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/windows-communication-foundation-wcf-in.html' title='Windows Communication Foundation (WCF) in .NET 3.0'/><author><name>.NET team</name><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://4.bp.blogspot.com/_dTCM5Vgc40g/R9isAzRa1iI/AAAAAAAAAbw/FA3cTcXlD98/s72-c/image2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-7904178859216097881</id><published>2008-03-12T19:21:00.000+05:30</published><updated>2008-03-12T19:24:06.653+05:30</updated><title type='text'>First Look at Silverlight 2</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Last September &lt;/span&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/09/04/silverlight-1-0-released-and-silverlight-for-linux-announced.aspx" target="_blank" mce_href="http://weblogs.asp.net/scottgu/archive/2007/09/04/silverlight-1-0-released-and-silverlight-for-linux-announced.aspx"&gt;&lt;span style="font-family:verdana;"&gt;we shipped Silverlight 1.0 for Mac and Windows&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, and announced our plans to deliver Silverlight on Linux.  Silverlight 1.0 focused on enabling rich media scenarios in a browser, and supports a JavaScript/AJAX programming model.&lt;br /&gt;We are shortly going to release the first public beta of Silverlight 2, which will be a major update of Silverlight that focuses on enabling Rich Internet Application (RIA) development.  This is the first of several blog posts I'll be doing over the weeks and months ahead that talk in more depth about it.&lt;br /&gt;Cross Platform / Cross Browser .NET Development&lt;br /&gt;Silverlight 2 includes a cross-platform, cross-browser version of the .NET Framework, and enables a rich .NET development platform that runs in the browser.  Developers can write Silverlight applications using any .NET language (including VB, C#, JavaScript, IronPython and IronRuby).  We will ship Visual Studio 2008 and Expression Studio tool support that enables great developer / designer workflow and integration when building Silverlight applications.&lt;br /&gt;This upcoming Beta1 release of Silverlight 2 provides a rich set of features for RIA application development.  These include:&lt;br /&gt;WPF UI Framework: Silverlight 2 includes a rich WPF-based UI framework that makes building rich Web applications much easier.  In includes a powerful graphics and animation engine, as well as rich support for higher-level UI capabilities like controls, layout management, data-binding, styles, and template skinning.  The WPF UI Framework in Silverlight is a compatible subset of the WPF UI Framework features in the full .NET Framework, and enables developers to re-use skills, controls, code and content to build both rich cross browser web applications, as well as rich desktop Windows applications.&lt;br /&gt;Rich Controls: Silverlight 2 includes a rich set of built-in controls that developers and designers can use to quickly build applications.  This upcoming Beta1 release includes core form controls (TextBox, CheckBox, RadioButton, etc), built-in layout management panels (StackPanel, Grid, Panel, etc), common functionality controls (Slider, ScrollViewer, Calendar, DatePicker, etc), and data manipulation controls (DataGrid, ListBox, etc).  The built-in controls support a rich control templating model, which enables developers and designers to collaborate together to build highly polished solutions.&lt;br /&gt;Rich Networking Support: Silverlight 2 includes rich networking support.  It includes out of the box support for calling REST, WS*/SOAP, POX, RSS, and standard HTTP services.  It supports cross domain network access (enabling Silverlight clients to directly access resources and data from resources on the web).  Beta1 also includes built-in sockets networking support.&lt;br /&gt;Rich Base Class Library: Silverlight 2 includes a rich .NET base class library of functionality (collections, IO, generics, threading, globalization, XML, local storage, etc).  It includes rich APIs that enable HTML DOM/JavaScript integration with .NET code.  It also includes LINQ and LINQ to XML library support (enabling easy transformation and querying of data), as well as local data caching and storage support.  The .NET APIs in Silverlight are a compatible subset of the full .NET Framework. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7904178859216097881?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7904178859216097881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7904178859216097881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7904178859216097881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7904178859216097881'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/first-look-at-silverlight-2.html' title='First Look at Silverlight 2'/><author><name>.NET team</name><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-2557049885090666521.post-3152860922870540672</id><published>2008-03-12T19:17:00.000+05:30</published><updated>2008-03-12T19:19:12.527+05:30</updated><title type='text'>Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;LINQ (language integrated query) is one of the new features provided with VS 2008 and .NET 3.5.  LINQ makes the concept of querying data a first class programming concept in .NET, and enables you to efficiently express queries in your programming language of choice.&lt;br /&gt;One of the benefits of LINQ is that it enables you to write type-safe queries in VB and C#.  This means you get compile-time checking of your LINQ queries, and full intellisense and refactoring support over your code.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx"&gt;&lt;span style="font-family:verdana;"&gt;http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-3152860922870540672?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/3152860922870540672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=3152860922870540672' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3152860922870540672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3152860922870540672'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/dynamic-linq-part-1-using-linq-dynamic.html' title='Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)'/><author><name>.NET team</name><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-2557049885090666521.post-6629092938004919462</id><published>2008-03-12T19:14:00.000+05:30</published><updated>2008-03-12T19:16:31.670+05:30</updated><title type='text'>Free Patterns and Practices Guidance Explorer for ASP.NET and .NET</title><content type='html'>&lt;a href="http://blogs.msdn.com/jmeier/"&gt;&lt;span style="font-family:verdana;"&gt;JD Meier&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; from the &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/practices/"&gt;&lt;span style="font-family:verdana;"&gt;Prescriptive Architecture Guidance Group&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; (aka PAG) at Microsoft stopped by my office this morning to show me the new Guidance Explorer tool he has been working on.  This is a cool WinForms client application that aggregates PAG guidance and suggestions, and allows you to search and sort across it.  This makes it ideal for quickly reviewing checklists of suggestions for ASP.NET projects.  Each guidance rule covers why it should be followed, and includes instructions on how to implement it.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Reference:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2006/06/29/Free-Patterns-and-Practices-Guidance-Explorer-for-ASP.NET-and-.NET.aspx"&gt;&lt;span style="font-family:verdana;"&gt;http://weblogs.asp.net/scottgu/archive/2006/06/29/Free-Patterns-and-Practices-Guidance-Explorer-for-ASP.NET-and-.NET.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-6629092938004919462?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6629092938004919462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6629092938004919462' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6629092938004919462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6629092938004919462'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/free-patterns-and-practices-guidance.html' title='Free Patterns and Practices Guidance Explorer for ASP.NET and .NET'/><author><name>.NET team</name><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-2557049885090666521.post-3210865001568854303</id><published>2008-03-12T16:20:00.004+05:30</published><updated>2008-12-11T19:07:09.910+05:30</updated><title type='text'>What is new in .NET 3.0 ?</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;c# 3.0 features&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;"&gt;what is new in .NET 3.5?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;First, as you no doubt know by now, .NET 3.0 is what we were calling WinFx until last week and is composed of (among other things):&lt;br /&gt;&lt;br /&gt;Technology Name (Acronym) [Former Code Name]&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Windows Presentation Foundation Classes (WPF) [Avalon] &lt;/span&gt;&lt;/strong&gt;- Arguably the heart of .NET 3, this is the technology for building rich Windows applications with special features for managing layout, text, 2-d and 3-d graphics and much more.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176810050812565010" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9e5UDRa1hI/AAAAAAAAAbo/v87FJkmLlCk/s400/Orcas.png" border="0" /&gt;Nothing new in .NET3.5 except some small features.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Windows Communication Foundation Classes (WCF) [Indigo]&lt;/span&gt;&lt;/strong&gt; - A new framework for inter-process communication that will change the way we interact with web services and the way we implement remoting. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Windows Workflow Foundation Classes (WF)&lt;/span&gt;&lt;/strong&gt; - You’d think this would be WWF but the World Wide Wrestling Foundation thinks differently. This is a framework for creating workflow engines that can be incorporated into your application&lt;br /&gt;Info Spaces [InfoCards] - A very nice way to deal with controlling how you identify yourself and how much information you provide on the web. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;At the same time that .NET 3 is coming out, ASP.NET is changing, though not quite simultaneously and not as part of the .NET 3.0 release. The key change to ASP.NET will be the release of ATLAS, the .NET Ajax technology and controls.&lt;br /&gt;While all this is happening, Microsoft will also be getting ready to release ORCAS - the next release of Visual Studio, and, oh by the way, C# 3 (with some very impressive new features and the next release of Visual Basic.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-3210865001568854303?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/3210865001568854303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=3210865001568854303' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3210865001568854303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3210865001568854303'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/what-is-net-30.html' title='What is new in .NET 3.0 ?'/><author><name>.NET team</name><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://4.bp.blogspot.com/_dTCM5Vgc40g/R9e5UDRa1hI/AAAAAAAAAbo/v87FJkmLlCk/s72-c/Orcas.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-5410714134826830438</id><published>2008-03-12T15:58:00.002+05:30</published><updated>2008-03-12T16:06:32.054+05:30</updated><title type='text'>Top 10 new features in SQL Server 2005</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;What is new in SQL Server 2005?&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;color:#ff6600;"&gt;New features in Sql Server 2005&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;color:#ff6600;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;1. T-SQL (Transaction SQL) enhancements&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;T-SQL is the native set-based RDBMS programming language offering high-performance data access. It now incorporates many new features including error handling via the TRY and CATCH paradigm, Common Table Expressions (CTEs), which return a record set in a statement, and the ability to shift columns to rows and vice versa with the PIVOT and UNPIVOT commands.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;2. CLR (Common Language Runtime)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The next major enhancement in SQL Server 2005 is the integration of a .NET compliant language such as C#, ASP.NET or VB.NET to build objects (stored procedures, triggers, functions, etc.). This enables you to execute .NET code in the DBMS to take advantage of the .NET functionality. It is expected to replace extended stored procedures in the SQL Server 2000 environment as well as expand the traditional relational engine capabilities.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;3. Service Broker&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The Service Broker handles messaging between a sender and receiver in a loosely coupled manner. A message is sent, processed and responded to, completing the transaction. This greatly expands the capabilities of data-driven applications to meet workflow or custom business needs.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;4. Data encryption&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL Server 2000 had no documented or publicly supported functions to encrypt data in a table natively. Organizations had to rely on third-party products to address this need. SQL Server 2005 has native capabilities to support encryption of data stored in user-defined databases.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;5. SMTP mail&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Sending mail directly from SQL Server 2000 is possible, but challenging. With SQL Server 2005, Microsoft incorporates SMTP mail to improve the native mail capabilities. Say "see-ya" to Outlook on SQL Server!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;6. HTTP endpoints&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You can easily create HTTP endpoints via a simple T-SQL statement exposing an object that can be accessed over the Internet. This allows a simple object to be called across the Internet for the needed data.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;7. Multiple Active Result Sets (MARS)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;MARS allow a persistent database connection from a single client to have more than one active request per connection. This should be a major performance improvement, allowing developers to give users new capabilities when working with SQL Server. For example, it allows multiple searches, or a search and data entry. The bottom line is that one client connection can have multiple active processes simultaneously.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;8. Dedicated administrator connection&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;If all else fails, stop the SQL Server service or push the power button. That mentality is finished with the dedicated administrator connection. This functionality will allow a DBA to make a single diagnostic connection to SQL Server even if the server is having an issue.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;9. SQL Server Integration Services (SSIS)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SSIS has replaced DTS (Data Transformation Services) as the primary ETL (Extraction, Transformation and Loading) tool and ships with SQL Server free of charge. This tool, completely rewritten since SQL Server 2000, now has a great deal of flexibility to address complex data movement.&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;10. Database mirroring:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;It's not expected to be released with SQL Server 2005 at the RTM in November, but I think this feature has great potential. Database mirroring is an extension of the native high-availability capabilities. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5410714134826830438?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5410714134826830438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5410714134826830438' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5410714134826830438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5410714134826830438'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/top-10-new-features-in-sql-server-2005.html' title='Top 10 new features in SQL Server 2005'/><author><name>.NET team</name><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-2557049885090666521.post-5654133844717746722</id><published>2008-03-12T14:38:00.003+05:30</published><updated>2008-03-12T15:54:35.349+05:30</updated><title type='text'>Restore Database Backup using SQL Script (T-SQL)</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;How to restore database in Sqlserver2005?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Database YourDB has full backup YourBaackUpFile.bak. It can be restored using following two steps. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Step 1: Retrive the Logical file name of the database from backup.RESTORE FILELISTONLY FROM DISK = 'D:BackUpYourBaackUpFile.bak'&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;Step 2: Use the values in the LogicalName Column in following Step.--Make Database to single user Mode&lt;br /&gt;&lt;br /&gt;ALTER DATABASE YourDB&lt;br /&gt;SET SINGLE_USER WITH ROLLBACK IMMEDIATE&lt;br /&gt;--Restore Database&lt;br /&gt;RESTORE DATABASE YourDB&lt;br /&gt;FROM DISK = 'D:BackUpYourBaackUpFile.bak'&lt;br /&gt;WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',&lt;br /&gt;MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.mdf'&lt;br /&gt;--If there is no error in statement before database will be in multiuser mode.&lt;br /&gt;--If error occurs please execute following command it will convert database in multi user.&lt;br /&gt;ALTER DATABASE YourDB SET MULTI_USER&lt;br /&gt;GO&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&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/2557049885090666521-5654133844717746722?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5654133844717746722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5654133844717746722' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5654133844717746722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5654133844717746722'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/restore-database-backup-using-sql.html' title='Restore Database Backup using SQL Script (T-SQL)'/><author><name>.NET team</name><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-2557049885090666521.post-7771946637972606116</id><published>2008-03-12T14:34:00.000+05:30</published><updated>2008-03-12T14:37:32.095+05:30</updated><title type='text'>When I open C drive by double click it'll pop up Open With windows and ask me to choose the program to open C drive?</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;When I open C drive by double click it'll pop up Open With windows and ask me to choose the program to open C drive?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ans:&lt;br /&gt;&lt;br /&gt;This is due to pest in your system. To get rid of this you remove the autorun.inf file from the root directory of C: drive.&lt;br /&gt;&lt;br /&gt;use the following steps to find the autorun.inf&lt;br /&gt;&lt;br /&gt;1) Open command prompt using windows+R and type cmd in the text box and press enter.&lt;br /&gt;&lt;br /&gt;2) In command prompt type dir/a. example: c:\&gt;dir/a&lt;br /&gt;&lt;br /&gt;By this you can find the autorun.inf&lt;br /&gt;&lt;br /&gt;3) Just find the autorun.inf and remove it.&lt;br /&gt;&lt;br /&gt;To remove this file you should have admin privileges.&lt;br /&gt;This you can do from command prompt by using attrib.&lt;br /&gt;Remove the Hidden, read-only and system attributes.&lt;br /&gt;To know the usage of attrib command just type attrib/? In your command prompt.&lt;br /&gt;Ex: c:\&gt;attrib/?&lt;br /&gt;Then remove the file directly.&lt;br /&gt;&lt;br /&gt;This will remove pest in your system.&lt;br /&gt;Don’t keep .inf files in your root directory.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7771946637972606116?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7771946637972606116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7771946637972606116' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7771946637972606116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7771946637972606116'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/when-i-open-c-drive-by-double-click.html' title='When I open C drive by double click it&apos;ll pop up Open With windows and ask me to choose the program to open C drive?'/><author><name>.NET team</name><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-2557049885090666521.post-4399510547690374631</id><published>2008-03-12T10:25:00.001+05:30</published><updated>2008-03-12T10:34:26.059+05:30</updated><title type='text'>Unity IoC Dependency Injection and ASP.NET Model-View-Presenter</title><content type='html'>&lt;a href="http://www.pnpguidance.net/Post/UnityIoCDependencyInjectionASPNETModelViewPresenter.aspx"&gt;Unity IoC Dependency Injection and ASP.NET Model-View-Presenter&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The Unity IoC Container can be used in your ASP.NET Web Applications to provide dependency injection, especially when using Model-View-Presenter. There are several ways that one can use Unity to wire-up the presenter class and its dependencies to the ASP.NET view. In this example, I will use a Page Base Class that accesses the UnityContainer on the HttpApplication Class and uses Unity to create an instance of the Presenter Class associated with the view.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-4399510547690374631?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4399510547690374631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4399510547690374631' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4399510547690374631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4399510547690374631'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/unity-ioc-dependency-injection-and.html' title='Unity IoC Dependency Injection and ASP.NET Model-View-Presenter'/><author><name>.NET team</name><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-2557049885090666521.post-6105144817957789862</id><published>2008-03-11T16:22:00.003+05:30</published><updated>2008-03-11T17:21:00.171+05:30</updated><title type='text'>export GridView to Word  using ASP.NET 2.0 and C#.</title><content type='html'>&lt;span style="font-family:verdana;"&gt;First,you need to import the namespace from System.Data.SqlClient.&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;The System.Data.SqlClient namespace contains The System.Data.SqlClient namespace is the .NET Framework Data Provider for SQL Server.The .NET Framework Data Provider for SQL Server describes a collection of classes used to access a SQL Server database in the managed space. In tutorial, we need "AddHeader" and "ContentType" to do the work.The AddHeader method adds a new HTML header and value to the response sent to the client. It does not replace an existing header of the same name. After a header has been added, it cannot be removed. The ContentType property specifies the HTTP content type for the response. If no ContentType is specified, the default is text/HTML. We use the Button1_Click event to do the work. We then call "Response.AddHeader" to export a file which is named FileName.doc. We then use "Response.ContentType" to denotes the type of the file being exported.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.Buffer = true;&lt;br /&gt;Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");&lt;br /&gt;Response.ContentEncoding = System.Text.Encoding.UTF7;&lt;br /&gt;Response.ContentType = "application/vnd.word";&lt;br /&gt;System.IO.StringWriter oStringWriter = new System.IO.StringWriter();&lt;br /&gt;System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);&lt;br /&gt;this.GridView1.RenderControl(oHtmlTextWriter);&lt;br /&gt;Response.Output.Write(oStringWriter.ToString());&lt;br /&gt;Response.Flush();&lt;br /&gt;Response.End();&lt;br /&gt;}&lt;br /&gt;public override void VerifyRenderingInServerForm(Control control)&lt;br /&gt;{ }&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;The front end GridViewExportWordCsharp.aspx page looks something like this:&lt;br /&gt;asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Export to Word"Width="99px" asp:GridView ID="GridView1" runat="server"/asp:GridView&lt;br /&gt;&lt;br /&gt;The flow for the code behind page is as follows.&lt;br /&gt;&lt;span style="font-size:85%;color:#ff6600;"&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.Text;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;string ConnectionString = "Data Source=(local);&lt;br /&gt;Initial Catalog=pubs;&lt;br /&gt;User Id=sa;&lt;br /&gt;Password=sa123";&lt;br /&gt;SqlConnection cn1;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (!Page.IsPostBack)&lt;br /&gt;{&lt;br /&gt;SqlConnection cn = new SqlConnection(ConnectionString);&lt;br /&gt;cn.Open();&lt;br /&gt;cn1 = new SqlConnection(ConnectionString);&lt;br /&gt;cn1.Open();&lt;br /&gt;SqlCommand cmd = new SqlCommand("select * from [authors]", cn);&lt;br /&gt;SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);&lt;br /&gt;GridView1.DataSource = dr;&lt;br /&gt;GridView1.DataBind();&lt;br /&gt;dr.Close();&lt;br /&gt;cmd.Dispose();&lt;br /&gt;cn.Dispose();&lt;br /&gt;cn1.Dispose();&lt;br /&gt;cn = cn1 = null;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.Buffer = true;&lt;br /&gt;Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");&lt;br /&gt;Response.ContentEncoding = System.Text.Encoding.UTF7;&lt;br /&gt;Response.ContentType = "application/vnd.word";&lt;br /&gt;System.IO.StringWriter oStringWriter = new System.IO.StringWriter();&lt;br /&gt;System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);&lt;br /&gt;this.GridView1.RenderControl(oHtmlTextWriter);&lt;br /&gt;Response.Output.Write(oStringWriter.ToString());&lt;br /&gt;Response.Flush();&lt;br /&gt;Response.End();&lt;br /&gt;}&lt;br /&gt;public override void VerifyRenderingInServerForm(Control control)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&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/2557049885090666521-6105144817957789862?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6105144817957789862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6105144817957789862' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6105144817957789862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6105144817957789862'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/export-gridview-to-word-using-aspnet-20.html' title='export GridView to Word  using ASP.NET 2.0 and C#.'/><author><name>.NET team</name><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-2557049885090666521.post-2163273691095657909</id><published>2008-03-11T16:04:00.003+05:30</published><updated>2008-03-12T09:55:14.769+05:30</updated><title type='text'>How to do time taking operations in asp.net?</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;How to avoid request timeout?&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;have a web page with a single button that causes postback.&lt;br /&gt;The button_OnClick method takes some time to finish, something like 30 minutes.&lt;br /&gt;After 5-10 minutes the page goes to "The Page Cannot Be Displayed" screen.&lt;br /&gt;I changed the timeout values in IIS, but it didn't make any change.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Try setting the httpRuntime node in your web.config. You can set things like maximum upload size, or execution timeout. "executionTimeout" is in seconds.&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;configuration&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;system.web&lt;br /&gt;!-- MAX UPLOAD FILE SIZE: 100MB HTTP TIMEOUT: 30MIN--&lt;br /&gt;httpRuntime maxRequestLength="102400" executionTimeout="1800"/&lt;br /&gt;/system.web&lt;br /&gt;/configuration&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;I used this for an app that needed to stay running for half an hour (it created like 2300+ zip files).&lt;br /&gt;&lt;strong&gt;use open and close angular brackets in the code&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-2163273691095657909?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/2163273691095657909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=2163273691095657909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2163273691095657909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2163273691095657909'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/how-to-do-time-taking-operations-in.html' title='How to do time taking operations in asp.net?'/><author><name>.NET team</name><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-2557049885090666521.post-1047933323886803667</id><published>2008-03-11T15:50:00.002+05:30</published><updated>2008-03-11T16:03:02.198+05:30</updated><title type='text'>Disable some ads in AdRotator XML</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Is there a property that can be used to disable an AD in the ads xml file?&lt;/span&gt;&lt;/strong&gt; which would result in ad not being displayed..&lt;br /&gt;Something like this --&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="font-size:78%;color:#ff6600;"&gt;openangular barcket&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt; Advertisements &lt;span style="font-size:78%;"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff6600;"&gt;close angular bracket&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff6600;"&gt;openangular barcket&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt; Ad Enabled="false" &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-size:78%;color:#ff6600;"&gt;close angular bracket&lt;br /&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;ad enabled="false"&gt;&lt;navigateurl&gt;...&lt;/navigateurl&gt; .... &lt;/ad&gt;&lt;/advertisements&gt;&lt;br /&gt;Ans:&lt;br /&gt;if you want to disable a AD, you can give the Impression property to "0", it will not displayed. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:78%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-1047933323886803667?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1047933323886803667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1047933323886803667' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1047933323886803667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1047933323886803667'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/disable-some-ads-in-adrotator-xml.html' title='Disable some ads in AdRotator XML'/><author><name>.NET team</name><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-2557049885090666521.post-265016377638768329</id><published>2008-03-11T15:10:00.002+05:30</published><updated>2008-03-11T15:44:28.938+05:30</updated><title type='text'>adding user controls dynamically in asp.net</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;How to add user control dynamically to a asp.net webpage?&lt;/strong&gt;&lt;/span&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;protected void addUserControl()&lt;br /&gt;    {&lt;br /&gt;        Control c = LoadControl("UserControl1.ascx");&lt;br /&gt;        c.ID = "uc";&lt;br /&gt;        this.Panel1.Controls.Add(c);&lt;br /&gt;    }&lt;br /&gt;    protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        addUserControl();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;References:&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;a href="http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls"&gt;http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls&lt;/a&gt; &lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;a href="http://www.singingeels.com/Articles/Dynamically_Created_Controls_in_ASPNET.aspx"&gt;http://www.singingeels.com/Articles/Dynamically_Created_Controls_in_ASPNET.aspx&lt;/a&gt;&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-265016377638768329?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/265016377638768329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=265016377638768329' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/265016377638768329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/265016377638768329'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/adding-user-controls-dynamically-in.html' title='adding user controls dynamically in asp.net'/><author><name>.NET team</name><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-2557049885090666521.post-1781585608123817179</id><published>2008-03-11T14:57:00.002+05:30</published><updated>2008-03-11T15:05:37.811+05:30</updated><title type='text'>How to expire a web page immediately?</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;If user clicked Sign Out, the session is abandon and the browser diaplays the login screen. If the user clicks the browser Back button, the previous page should not come back. How does it work?&lt;/span&gt;&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;You need to set the page to not cache and check if the session exists on page load and redirect to the login page if it doesn't. Something like:&lt;br /&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;SessionCheck();&lt;br /&gt;Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;}&lt;br /&gt;private void SessionCheck()&lt;br /&gt;{&lt;br /&gt;if (Session.Count == 0)&lt;br /&gt;{&lt;br /&gt;Response.Redirect("~/login.aspx");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&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/2557049885090666521-1781585608123817179?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1781585608123817179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1781585608123817179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1781585608123817179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1781585608123817179'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/how-to-expire-web-page-immediately_11.html' title='How to expire a web page immediately?'/><author><name>.NET team</name><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-2557049885090666521.post-153518159701479527</id><published>2008-03-11T14:55:00.000+05:30</published><updated>2008-03-11T14:57:11.393+05:30</updated><title type='text'>ASP.NET Wiki (Beta) has just launched</title><content type='html'>&lt;a href="http://www.hanselman.com/blog/" target="_blank"&gt;Scott Hanselman&lt;/a&gt; just &lt;a href="http://www.hanselman.com/blog/ASPNETWikiBeta.aspx" target="_blank"&gt;announced&lt;/a&gt; the launching of the &lt;a href="http://wiki.asp.net/" target="_blank"&gt;ASP.NET Wiki&lt;/a&gt; (Beta).  If you are wondering why a Wiki this is what Scott has to say:  "To provide a targeted, categorized, human-hand-edited, and living Wiki for finding answers to ASP.NET questions."&lt;br /&gt;If you have some great content on your blog that is not in there, get it in there.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-153518159701479527?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/153518159701479527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=153518159701479527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/153518159701479527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/153518159701479527'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/aspnet-wiki-beta-has-just-launched.html' title='ASP.NET Wiki (Beta) has just launched'/><author><name>.NET team</name><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-2557049885090666521.post-7060894722195327042</id><published>2008-03-11T11:44:00.000+05:30</published><updated>2008-12-11T19:07:14.378+05:30</updated><title type='text'>Beginning SQL Server 2005 Reporting Services Part 1</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Sqlserver Reporting services&lt;/strong&gt; &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;by&lt;/span&gt; &lt;span style="color:#3366ff;"&gt;steve joubert&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;Building and deploying basic reports&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SSRS 2005 is the latest version of SQL Reporting Services, and ships with all versions of SQL Server 2005. SSRS allows you to quickly and easily create reports from multiple database sources. The finished reports can be presented directly from the reporting services website, or they can be displayed in your web- or Windows-based applications. Reports can be exported to multiple formats, including comma delimited text, XML, portable document format (pdf) and Microsoft Excel.&lt;br /&gt;&lt;br /&gt;This article is the first of four parts, which will provide in-depth coverage of SQL Server 2005 Reporting Services:&lt;br /&gt;&lt;br /&gt;Part 1 covers the basics of the SSRS. It demonstrates how to build quick, simple reports and will familiarize you with the basic Report Designer environment&lt;br /&gt;Part 2 will cover use of custom functions, aggregate functions, sub-reporting, the matrix control, drill-downs, and sorting.&lt;br /&gt;Part 3 will take an in-depth look at the charting control&lt;br /&gt;Part 4 digs into the actual Report Definition Language (RDL) and the new Report Builder tool. &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Installing and configuring Reporting Services&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;After much debate, we decided that full installation and configuration details were outside the scope of an article focused on how to build basic reports using SSRS, especially as there are already several online resources that treat this area in detail. See, for example:&lt;br /&gt;&lt;/span&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms143736.aspx"&gt;&lt;span style="font-family:verdana;"&gt;http://msdn2.microsoft.com/en-us/library/ms143736.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;and&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.awprofessional.com/articles/article.asp?p=357694&amp;amp;seqNum=1&amp;amp;rl=1"&gt;&lt;span style="font-family:verdana;"&gt;http://www.awprofessional.com/articles/article.asp?p=357694&amp;amp;seqNum=1&amp;amp;rl=1&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Well worth reviewing are the details in the latter on the need to install SSL on any machine hosting SSRS.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;em&gt;&lt;strong&gt;---Editor's installation notes---&lt;br /&gt;&lt;/strong&gt;&lt;/em&gt;In order to test the reports in this article, I went through a single-machine installation on Windows XP (meaning that SQL Server 2005, Reporting Services, and much more, are all installed on my poor laptop). Since I didn't install SSRS when I installed SQL Server 2005 (I didn't have IIS installed at the time), I had to first install IIS 5.1, and then Reporting Services (from the SS2005 disks). I then jumped immediately into Reporting Services Configuration Manager tool (All Programs ¬ SQL Server 2005 ¬ Configuration tools). The left panel acts as a sort of checklist of items to configure:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176364920402007250" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R9YkeDRa1NI/AAAAAAAAAZI/ecMYWdeMpCg/s400/268-ScreenShot1.gif" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;All went well until the Database Setup. Because I had not installed SSRS at the same time that I installed SQL Server, the ReportServer and ReportServerTempDB were not created by default. These databases hold all the report definitions and reporting server configuration information. Connecting to SQL Server using Service Credentials, the databases appeared to be created, but I received an error suggesting that I didn't have permissions to perform the requested task, and a red cross remained next to the Database Setup icon. This had me stumped for a while – eventually I appeared to solve it by hopping to the Server Status section, stopping the Report Server, opening SSMS and deleting both the ReportServer and ReportServerTempDB databases, and then restarting the Report Server and trying again! Even though I swear this didn't work the first time I tried it, it seemed to do the trick the second time (while I was on the phone moaning to Steve that I couldn't get it to work!). However, I'm still not clear why I had the problem in the first place – or why it suddenly went away.&lt;br /&gt;This wasn't quite the end of my problems. Installing SSRS creates two new virtual directories under the default website on IIS. By default, they are named Reports and ReportServer. The ReportServer site hosts a web service for running and managing reports. The Reports site allows you upload reports from a browser and run reports over the web. When I tried to navigate to http://localhost/ReportServer I received the following error: "Failed to access IIS metabase". Fortunately, the information on the error page is quite useful (for a change) and this, coupled with a quick Google search, led me to grant access to the metabase to the ASPNET user account by executing the following from the directory housing the aspnet_regiis executable (WINDOWS\Microsoft.NET\Framework\v2.0.50727, in my case):&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;aspnet_regiis -ga ASPNET&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This did the trick, and I was up and running. I received some raised eyebrows here when I proposed to install SSRS. It made my long-suffering sys admin team particularly nervous. The 2000 version of SSRS seems to have a very bad reputation among the Red Gate team, both as a performance nightmare, and in one case for "completely annihilating" a developer's machine. However, the above slight quirks aside, the SSRS 2005 experience seems pretty smooth and I've had no real performance, or other, issues. So far.-----End of Editor's note----&lt;br /&gt;Once you've completed the installation and configuration process, the first thing to do is download the code file for this article (see the Code Download link in the speech bubble to the right of the article title). The code file contains a sample Visual Studio project and a SQL Script for creating the ReportDemo database. You will need this database if you want to follow the examples in this series of articles so go ahead and create the database using the ReportingDemoDatabaseScript.sql script or, alternatively, by restoring the provided ReportingDemo.bak file.&lt;br /&gt;If you are using SQL Server Authentication on your SQL Server you will also need to set up a login with permissions to the ReportDemo database (for the examples, I set up a login called DemoUser as a DBO on my ReportDemo database).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Using the Report Wizard&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There are two ways to create SSRS Reports. You can build the report manually, or you can use the Report Wizard to give yourself a head start. For this first report, we are going to take advantage of the wizard. Start a new Business Intelligence project in Visual Studio 2005. Then, from the menu, select Project &gt; Add New Item. Select the Report Wizard option and call the file "FirstReportWZ.rdl". Click Add. Click Next on the Welcome screen and this will bring you to the Select the Data Source screen:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176365457272919266" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9Yk9TRa1OI/AAAAAAAAAZQ/fJjRnOqqNrw/s400/268-ScreenShot2.gif" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Select the New data source radio button and give the data source a name. Select Microsoft SQL Server as the type.&lt;br /&gt;Note:Use of the Shared data source option is actually a better option in most cases but, for the sake of this example, we will just create a new data source. We're going to set up a shared data source later in this article.&lt;br /&gt;Click the Edit button to bring up the Connection Properties dialog:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176365929719321842" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R9YlYzRa1PI/AAAAAAAAAZY/5f9u8MmJN4E/s400/268-ScreenShot3.gif" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Enter or select a server name. The default is to log on using Windows Authentication. If you are using SQL Server Authentication, choose that setting, and enter the username and password. Finally, select a database, in this case ReportingDemo. Make sure you test the connection before you click OK.&lt;br /&gt;Next up is the Design the Query screen. You can use the Query Builder by clicking the button at the top left, but in this case simply enter "Select * From Customer" into the Query string text box and click Next. On the Select the Report Type simply select the type you prefer (tabular or matrix) and hit Next.&lt;br /&gt;This brings up the Design the Table screen:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176366281906640130" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9YltTRa1QI/AAAAAAAAAZg/as26G_xoKtg/s400/268-ScreenShot4.gif" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Select State in the Available fields box and click the Group button. This will group the data in the result set by State. Select Next. On the Choose the Table Layout page, select the Stepped option and check the Enable Drilldown checkbox. On the next screen, choose a style for your report (I chose Ocean) and click Next.&lt;br /&gt;This brings up the final screen, Completing the Wizard:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176366646978860306" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YmCjRa1RI/AAAAAAAAAZo/pWLpoGLaA1Y/s400/268-ScreenShot5.gif" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;It shows a summary of your report options, and gives you an opportunity to rename the report and to preview it. Click Finish to end the wizard.&lt;br /&gt;You should be shown the report in the standard Report Designer:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176366977691342114" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R9YmVzRa1SI/AAAAAAAAAZw/vA4st77EAxo/s400/268-ScreenShot6.gif" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;There are three tabs: Data, Layout and Preview. You should be on the Layout tab. Click on the Preview tab to view the report. Since this report doesn't take any arguments, it will run as soon as you click on the tab.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176367377123300658" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R9YmtDRa1TI/AAAAAAAAAZ4/YnKn1cy7pUE/s400/268-ScreenShot7.gif" border="0" /&gt;&lt;br /&gt;Use the +/- symbols next to the State abbreviations to expand and collapse the grouping of the report.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Manual report creation&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;The previous section, while perhaps overly simplistic, does show you how to get a report up and running with zero code and zero property setting. Obviously, such reports will not meet most development requirements, but do not discount this option as a starting point for more complicated reports. Once you've created a report with the Report Wizard, you are free to make any modifications to it.&lt;br /&gt;In this section, we are going to create a more realistic report from scratch, including how to create and use a shared data source object, stored procedures, and how to format your report, set report properties and use report parameters.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Creating a shared data source&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Before we start the report, we are going to build a shared data source i.e. a data source that is common to, and can be used by, all of the reports on a reporting server. While each report can contain its own connection information, it is good practice to use shared data sources, as it will save you a lot time and headaches. This way, you only have to set the connection information once. For example, let's say your company has Development, Test and Production environments. If you put the connection information into each report, you will have to change it each time when you publish to Development, Test and Production. If you use a shared data source, you still have to set up a data source object for each of three environments, but you can simply publish the report to each environment, and they will automatically use the connection information associated with that environment.&lt;br /&gt;From the menu select Project &gt; Add New Item &gt; Select Data Source. On the General tab, call the data source "ReportsDB". Leave the Type as Microsoft SQL Server. Click the Edit button on the right, and enter the connection information for Reporting Demo, as before. Click OK on the Shared Data Source screen and the data source is done.&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Add a new report&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;From the menu select Project &gt; Add New Item. Select Report and name it "FirstReportMan.rdl". A new report will be added to the project, and the Report Designer will open at the Data tab. At this point, let's take a closer look at the Report Designer tool. At the top of the Report Designer window are three tabs: Data, Layout and Preview. The Data tab is used to build data sources for your report. The Layout tab is the physical report designer where you set up the header, the footer and the data presentation of the report. The Preview tab allows you to actually run the report from Visual Studio 2005, without having to publish it to a report server first. If your report takes parameters, the Preview tab will ask you to fill them out before it runs the report.&lt;br /&gt;The first thing we need to do is get data into our report. At the top of the Data tab choose &lt;new&gt;from the dropdown list:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176367720720684354" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R9YnBDRa1UI/AAAAAAAAAaA/X9zsLsjcfCw/s400/268-ScreenShot8.gif" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;The Dataset dialog opens:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176368158807348562" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YnajRa1VI/AAAAAAAAAaI/5GpeaKCdeYs/s400/268-ScreenShot9.gif" border="0" /&gt;&lt;br /&gt;Name the dataset "ReportData", and select the ReportsDB data source from the dropdown. Select StoredProcedure as the command type, and enter "spr_CustomerSelectAll" in the query string box. Click OK to close the dialog.&lt;br /&gt;Note:&lt;br /&gt;spr_CustomerSelectAll is a very simple, parameter-less stored procedure that selects all of the columns from the Customer table. The source code is included in the ReportingDemoDatabaseScript.sql script with the code download.&lt;br /&gt;Test the dataset by clicking on the big red exclamation point at the top of the report designer. This executes the query and displays the results. You can repeat these steps if you wish to add multiple datasets to your report.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Setting up the report display&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Next, switch to the Layout tab. This is where you actually build the report display. Start by dragging a table from the Toolbox, onto the Body section of the report. By default, the table shows a header row at the top, a detail row in the middle and a footer row at the bottom. You can add additional columns to the table by right-clicking on one of the columns and selecting one of the two Insert Column options.&lt;br /&gt;Click on the Datasets tab under Toolbox on the left-hand side of the Visual Studio environment. You should see the ReportData dataset. Expand it, select FirstName and drag it to the first cell of the body row of the table. This will display the First Name field in the first column. Now put the LastName in the second column, and the CustomerStatus in the third:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176368601188980066" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9Yn0TRa1WI/AAAAAAAAAaQ/WZMoVgHSsAY/s400/268-ScreenShot10.gif" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;Note that, when you drag the column FirstName into the body row of the table, SSRS make a guess as to what to call the row. It calls it "First Name". You can click on the Preview tab to view the report.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Adding formatting&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;OK, so we have a basic, very plain, report. Let's add some formatting to make it look good. Let's add the DateOfBirth column to the table. You can expand and shrink the size of the columns by highlighting and dragging:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176369150944793970" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9YoUTRa1XI/AAAAAAAAAaY/NiMkWCkahko/s400/268-ScreenShot11.gif" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;If you wish to get rid of the footer row of the table and then click on any field in the table. You will see a grey box surround the table. Right-click on the icon at the beginning of the body row and then click the Table Footer option to deselect it.&lt;br /&gt;The table header is next. To format all the cells in the header in the same way, click and drag over all the cells to select them. Open the Properties window and set background color, font, and so on. &lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176370306290996626" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YpXjRa1ZI/AAAAAAAAAao/AZflscTXkBg/s400/268-ScreenShot12.gif" border="0" /&gt;Note, however, that if you wish to change the justification of the text or the size, then you do so using the main menu at the top, not via the properties window. Again, you can click on the Preview tab to view the report.&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Add a report header&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;The table already has a header, but the report can also have a header and footer. Report headers and footers appear on every page of the report. Put the Report Designer in Layout mode and select Report &gt; Page Header from the menu. A new band labeled Page Header appears on the report above the body. Drag a text box onto the header and click directly on it. Type "My First Report", not in the Properties window, but right on the control.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176372230436345250" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YrHjRa1aI/AAAAAAAAAaw/olHEETv42aM/s400/268-Screenshot13.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;To adjust the text style and size of your heading, highlight the text box and use the option from the top menu.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Formatting&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Each field can have formatting. Let's deal with that ugly Date of Birth field. The time information is superfluous, so let's format the date properly. Right-click on the cell that contains the date of birth, and choose Properties. Next, select the Format tab.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176372647048172978" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R9YrfzRa1bI/AAAAAAAAAa4/nU8-4z_oe1M/s400/268-ScreenShot14.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Click on the second button (labeled "…") to the right of the Format code field. When the dialog opens, use the standard options. Select Date in the list on the left, then choose the sample date format you want on the right. Click OK to close the dialog.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176373136674444738" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9Yr8TRa1cI/AAAAAAAAAbA/2irW9H9c-b0/s400/268-ScreenShot15.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Click OK to close the Properties window and then click on the Preview tab to view the report.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Setting report properties&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;To access the report properties, you need to be on the Layout tab of the Report Designer. When you click on this tab, a new menu item, Report, activates. This menu gives you options for turning on and off the report header and footer sections (as we have seen), adding embedded images, setting report properties, and setting report parameters.&lt;br /&gt;Setting up the report print settings is not intuitive, compared to other products. In the report Layout tab you see your report with a ruler across the top. That ruler is set up in inches. A standard sheet of paper is 8.5 x 11 inches. The default setting in SSRS is to have a 1-inch margin all the way around the content area. So, at 8.5 inches wide with a 1-inch margin on the left and another on the right, you have 6.5 inches for content. Any more, and the content beyond the 6.5 inches will spill over onto a second sheet of paper when printed. It will not automatically shift to Landscape.&lt;br /&gt;To get Landscape reports, you have to make the proper report settings. Navigate to the Layout tab of the Report Designer. From the Report menu select Report Properties. Switch to the Layout tab of the dialog box. To switch to Landscape printing, you need to change Page width to 11in and the Page height to 8.5in. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176373639185618386" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YsZjRa1dI/AAAAAAAAAbI/lrfJE_LukLc/s400/268-ScreenShot16.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;On the same Layout tab, you can also get up your report to display the data in multiple columns, and you can control the margins. By default, all the margins are set at 1 inch. Remember, if your report width, plus the right and left margins, is greater than the width of the printer, you will get spill-over when you print out your report.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Using parameters&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;There are two ways to add parameters to your reports. The first is to use parameters in the queries in your data sources. The second is to set up parameters through the Report Parameters dialog box. We will do both.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Query parameters&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;First, we will set up parameters using a data source query. Navigate to the Data tab, and click the "…" button right next the Dataset dropdown box. The Dataset dialog box opens and allows you to edit the query for the dataset. Change the Query string from "spr_CustomerSelectAll" to "spr_CustomerSelectByState".&lt;br /&gt;Note:spr_CustomerSelectByState accepts a parameter called StateCD that allows us to filter the data from the Customer table by State. Again, the source code is included in the ReportingDemoDatabaseScript.sql script with the code download.&lt;br /&gt;Click OK and then run the query by clicking the red exclamation point (!) on the Data tab toolbar. You will be prompted to enter a parameter value for StateCD (the State code). Enter "CA" and click OK. The query should return all the customers that live in California.&lt;br /&gt;Switch to the Preview tab. Instead of the report just running, there should be a place for you to enter a value for the "StateCD" and run the report. Enter "CA" and click the View Report button. You should see your report filtered by state.&lt;br /&gt;To edit the parameters, or to add new ones, switch to the Layout tab of the Report Designer and open the Report Parameters dialog from the Report menu. First, we are going to make the "State code" prompt a little more friendly. Select StateCD in the Parameters list box then, in the Parameters Properties box, change the prompt to read "State". In the Available values section enter "California" and "CA" on the first line. Enter "Louisiana" and "LA" on the second line.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176374270545810914" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9Ys-TRa1eI/AAAAAAAAAbQ/ul5CApuPZ_U/s400/268-ScreenShot17.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This will make the prompt for "State value" into a dropdown. You can also build additional datasets into your report, and use the values in those datasets as criteria for dropdowns.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Report parameters&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Now let's add a parameter that is not used in a query. Click the Add button in the Report Parameters dialog from the Report menu. Give the new parameter the name "ReportTitle". Its Data type should be String. Set the Prompt to "Report Title". Click OK and close the dialog box.&lt;br /&gt;Drag a new text box onto the report header area. Right-click on it and choose the Expression option. In the Edit Expression dialog select Parameters. Double-click on the ReportTitle parameter. This text box will now display the value you pass to the Report Title parameter. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9YteTRa1fI/AAAAAAAAAbY/TAGNtDA3D40/s1600-h/268-ScreenShot18.gif"&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176374820301624818" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R9YteTRa1fI/AAAAAAAAAbY/TAGNtDA3D40/s400/268-ScreenShot18.gif" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Switch to the Preview tab and try it out.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Publishing your reports&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Up to now, you have been running your reports in the Visual Studio 2005 environment but, to make them useful, you must publish them to a report server. The easiest way to do this is to have Visual Studio publish your reports.&lt;br /&gt;Start by right-clicking on Project in the Project Explorer and choose Properties.&lt;br /&gt;&lt;/span&gt;&lt;a href="http://2.bp.blogspot.com/_dTCM5Vgc40g/R9Yt_zRa1gI/AAAAAAAAAbg/kaLSCzmZx7I/s1600-h/268-ScreenShot19.gif"&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176375395827242498" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R9Yt_zRa1gI/AAAAAAAAAbg/kaLSCzmZx7I/s400/268-ScreenShot19.gif" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; Set TargetServerURL to the URL of your report server. Use the TargetReportFolder property to set up a folder for your reports. If the folder does not exist, the Publisher will create it for you. The other key thing to pay attention to here is the OverwriteDataSources property. When this property is set to "True", it will automatically copy over all your data source objects when you publish. When set to "False", it will copy any new data source objects, but it will not overwrite existing ones. This is important when dealing with development, test and production servers. You can publish a set of data source objects to each server, pointed at the correct database, and never have to worry about what database your reports are hitting in each environment.&lt;br /&gt;From the Build menu select Deploy Solution. This will publish the project to the selected folder on your report server. You can also deploy individual reports by right-clicking on the file in the Solution explorer and selecting Deploy.&lt;br /&gt;Once your report has been published, you can access and run it on your server through the browser at &lt;/span&gt;&lt;a href="http://servername/reportservername"&gt;&lt;span style="font-family:verdana;"&gt;http://servername/reportservername&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;. From the Home page, you should be able to find the folder you published to, with the reports in it. Select a report to run. At the top of the page you can enter any values for report parameters, and then run the report. From here, you can also print or export the report. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;Reference: &lt;a href="http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-1/"&gt;http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-1/&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7060894722195327042?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7060894722195327042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7060894722195327042' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7060894722195327042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7060894722195327042'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/beginning-sql-server-2005-reporting.html' title='Beginning SQL Server 2005 Reporting Services Part 1'/><author><name>.NET team</name><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://3.bp.blogspot.com/_dTCM5Vgc40g/R9YkeDRa1NI/AAAAAAAAAZI/ecMYWdeMpCg/s72-c/268-ScreenShot1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-9162869420210559906</id><published>2008-03-11T11:03:00.000+05:30</published><updated>2008-12-11T19:07:14.504+05:30</updated><title type='text'>Sqlserver Reporting Services Overview</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;Sqlserver Reporting Services&lt;/strong&gt;&lt;/span&gt; &lt;div&gt;&lt;span style="font-family:verdana;"&gt;SQL Server Reporting Services is a comprehensive, server-based solution that enables the creation, management, and delivery of both traditional, paper-oriented reports and interactive, Web-based reports. An integrated part of the Microsoft Business Intelligence framework, Reporting Services combines the data management capabilities of SQL Server and Microsoft Windows Server with familiar and powerful Microsoft Office System applications to deliver real-time information to support daily operations and drive decisions.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;An Integrated Architecture&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;SQL Server Reporting Services supports a wide range of common data sources, such as OLE DB and Open Database Connectivity (ODBC), as well as multiple output formats such as familiar Web browsers and Microsoft Office System applications. Using Microsoft Visual Studio .NET and the Microsoft .NET Framework, developers can leverage the capabilities of their existing information systems and connect to custom data sources, produce additional output formats, and deliver to a variety of devices.&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5176360341966869698" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 347px; CURSOR: hand; HEIGHT: 223px; TEXT-ALIGN: center" height="201" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R9YgTjRa1MI/AAAAAAAAAZA/3cFE2XWtgAM/s320/rsarchitecture.gif" width="332" border="0" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Full Reporting Life Cycle Support&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;SQL Server Reporting Services supports the full reporting life cycle, including:&lt;br /&gt;• &lt;strong&gt;Report authoring&lt;/strong&gt;. Report developers can create reports to be published to a report server by using Microsoft or other design tools that use Report Definition Language (RDL), an XML-based industry standard used to define reports.&lt;br /&gt;• &lt;strong&gt;Report management.&lt;/strong&gt; Report definitions, folders, and resources are published and managed as a Web service. Managed reports can be executed either on demand or on a specified schedule, and are cached for consistency and performance. New in SQL Server 2005 Reporting Services, administrators can use SQL Server Management Studio to organize reports and data sources, schedule report execution and delivery, and track reporting history.&lt;br /&gt;• &lt;strong&gt;Report delivery&lt;/strong&gt;. SQL Server Reporting Services supports both on-demand (pull) and event-based (push) delivery of reports. Users can view reports in a Web-based format or in e-mail.&lt;br /&gt;• &lt;strong&gt;Report security&lt;/strong&gt;. SQL Server Reporting Services implements a flexible, role-based security model to protect reports and reporting resources. The product includes extensible interfaces for integrating other security models as well.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Key Reporting Scenarios&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;SQL Server Reporting Services combines a single, complete reporting platform with a scalable and extensible architecture to meet a wide variety of reporting needs, including:&lt;br /&gt;• Enterprise reporting. Enterprises can use Reporting Services for their operational reporting or business intelligence applications. Using Reporting Services, corporate IT staff can design a variety of reports and deploy them to individuals throughout the enterprise.&lt;br /&gt;• Ad-hoc reporting. SQL Server 2005 Reporting Services includes Report Builder, a new ad-hoc reporting tool that enables business users to create their own reports and explore corporate data. Report Builder incorporates a user-friendly business query model that enables users to build reports without deep technical understanding of the underlying data sources.&lt;br /&gt;• Embedded reporting. Organizations can access predefined or ad-hoc reports from third-party applications that use Reporting Services and use these reports as-is, customize them, or create new ones for specific business needs.&lt;br /&gt;• Web-based reporting for partners and customers. Organizations can deploy interactive Web-based reports to deliver information to customers or partners over extranets or the Internet. Reporting Services isolates report consumers from the complexity of the underlying data sources, while providing personalization and interactivity. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;Reference&lt;/span&gt;: &lt;/span&gt;&lt;a href="http://www.microsoft.com/sql/technologies/reporting/overview.mspx"&gt;&lt;span style="font-family:verdana;"&gt;http://www.microsoft.com/sql/technologies/reporting/overview.mspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-9162869420210559906?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/9162869420210559906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=9162869420210559906' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/9162869420210559906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/9162869420210559906'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/sqlserver-reporting-services-overview.html' title='Sqlserver Reporting Services Overview'/><author><name>.NET team</name><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://1.bp.blogspot.com/_dTCM5Vgc40g/R9YgTjRa1MI/AAAAAAAAAZA/3cFE2XWtgAM/s72-c/rsarchitecture.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-2264922434520079052</id><published>2008-03-11T10:35:00.000+05:30</published><updated>2008-03-11T11:01:48.671+05:30</updated><title type='text'>change the CSS file dynamically in asp.net webpage</title><content type='html'>&lt;span style="font-family:verdana;"&gt;This is so that I can have an element ID duplicated in two different CSS files, and let my graphic designer tweak page designs without a developer having to change control IDs. There are CSS settings that will be specific to specific controls, so just doing everything with classes isn't really an option. Essentially, I want to be able to add the link href="Style1.css" type="text/css" rel="stylesheet" statement to the aspx, but change the css file name at runtime. The Page.StyleSheetTheme property looked promising, but it appears that I can't write to that. Anyone tried this before?&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Something like this should work:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;private void Page_Load(object sender, System.EventArgs e)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;bool useScript1 = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;string styleScript1 = "&lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;openangular barcket&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt; link rel=\"stylesheet\" type=\"text/css\" href=\"Style1.css\"/" &lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;close angular bracket&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;string styleScript2 = "&lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;openangular barcket&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt; link rel=\"stylesheet\" type=\"text/css\" href=\"Style2.css\"/" &lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;close angular bracket&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;;&lt;br /&gt;if ( useScript1 )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;this.RegisterClientScriptBlock("StyleScript", styleScript1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;this.RegisterClientScriptBlock("StyleScript", styleScript2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-2264922434520079052?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/2264922434520079052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=2264922434520079052' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2264922434520079052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2264922434520079052'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/change-css-file-dynamically-in-aspnet.html' title='change the CSS file dynamically in asp.net webpage'/><author><name>.NET team</name><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-2557049885090666521.post-6307261579990418094</id><published>2008-03-11T10:30:00.000+05:30</published><updated>2008-03-11T10:34:38.055+05:30</updated><title type='text'>Visual Studio .NET Debugger Does Not Stop on Breakpoints When You Debug ASP.NET Pages</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;When you debug ASP.NET pages, the Visual Studio .NET Debugger may not stop on breakpoints. For additional information about how to resolve this problem, click the article number below to view the article in the Microsoft Knowledge Base:&lt;/span&gt; &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;SYMPTOMS&lt;br /&gt;&lt;/strong&gt;When you debug ASP.NET applications in Visual Studio .NET, the debugger may not stop on breakpoints. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;CAUSE&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;This problem occurs because ASP.NET debugging is not enabled on the application. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;RESOLUTION&lt;br /&gt;&lt;/strong&gt;To resolve this problem, follow these steps in Visual Studio .NET:&lt;br /&gt;1.In Solution Explorer, select the project name.&lt;br /&gt;2.From the Project menu, click Properties.&lt;br /&gt;3.Click to expand the Configuration Properties node.&lt;br /&gt;4.Under Debugging, in the Enable ASP.NET Debugging list, click True.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-6307261579990418094?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6307261579990418094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6307261579990418094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6307261579990418094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6307261579990418094'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/visual-studio-net-debugger-does-not.html' title='Visual Studio .NET Debugger Does Not Stop on Breakpoints When You Debug ASP.NET Pages'/><author><name>.NET team</name><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-2557049885090666521.post-4914374593476432346</id><published>2008-03-11T10:20:00.000+05:30</published><updated>2008-03-11T10:29:59.298+05:30</updated><title type='text'>Cannot Debug ASP.NET Web Application</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;"&gt;When you debug an ASP.NET application in Microsoft Visual Studio .NET, you may receive the following Microsoft Development Environment error message:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;Error while trying to run project: Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. Run setup to install the Visual Studio .NET server components. If setup has been run, verify that a valid URL has been specified.&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation. Would you like to disable future attempts to debug ASP.NET pages for this project?&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;CAUSE&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;This error may occur if the Microsoft .NET Framework setup or installation was not completed correctly. When this occurs, the application mappings for ASP.NET file name extensions (such as .aspx) are not configured correctly in Microsoft Internet Information Services (IIS).To check whether the application mappings are correct, follow these steps:&lt;br /&gt;1. Click Start, point to Programs, point to Administrative Tools, and then click Internet Services Manager.&lt;br /&gt;2. Expand the node that corresponds to the local host (computer name), and then expand the Default Web Site node.&lt;br /&gt;3. Right-click your Web application directory, and then click Properties.&lt;br /&gt;4. On the Directory tab, under Application Settings, click Configuration.&lt;br /&gt;5. Click the App Mappings tab.&lt;br /&gt;6. On the App Mappings tab, under Application Mappings, check whether the .aspx extension is mapped to the following dynamic-link library (DLL):&lt;br /&gt;C:\Windows Directory\Microsoft.Net\Framework\&lt;version&gt;\aspnet_isapi.dll NOTE: You must replace Windows Directory in this path with the correct directory for your system and replace Version with the version of the .NET Frame work installed on your system.&lt;br /&gt;7. If the application mapping entry is not found, follow the steps in the "Resolution" section.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;RESOLUTION&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;To resolve this problem, use the Aspnet_regiis.exe administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single computer.To use the Aspnet_regiis.exe utility, follow these steps:&lt;br /&gt;1.Click Start, and then click Run.&lt;br /&gt;2.Type cmd in the Open box, and then click OK to open a command prompt.&lt;br /&gt;3.At the command prompt, use the cd command to change to the following directory:&lt;br /&gt;C:\Windows Directory\Microsoft.Net\Framework\VersionNote: You must replace Windows Directory in this path with the correct directory for your system and replace Version with the version of the .NET Frame work installed on your system.&lt;br /&gt;4.Type aspnet_regiis -i to configure the required application mappings correctly.&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;references:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt; &lt;/span&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/w2faa92k(vs.71).aspx"&gt;&lt;span style="font-family:verdana;"&gt;http://msdn2.microsoft.com/en-us/library/w2faa92k(vs.71).aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/318465/EN-US/"&gt;&lt;span style="font-family:verdana;"&gt;http://support.microsoft.com/kb/318465/EN-US/&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:78%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-4914374593476432346?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4914374593476432346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4914374593476432346' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4914374593476432346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4914374593476432346'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/cannot-debug-aspnet-web-application.html' title='Cannot Debug ASP.NET Web Application'/><author><name>.NET team</name><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-2557049885090666521.post-646480670818031609</id><published>2008-03-11T00:19:00.002+05:30</published><updated>2008-03-11T14:51:58.876+05:30</updated><title type='text'>How to expire a web page immediately?</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;If user clicked Sign Out, the session is abandon and the browser diaplays the login screen.  If the user clicks the browser Back button, the previous page should not come back.  How does it work?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;You need to set the page to not cache and check if the session exists on page load and redirect to the login page if it doesn't. Something like:&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   SessionCheck();&lt;br /&gt;  Cache.SetCacheability(HttpCacheability.NoCache);&lt;br /&gt;}&lt;br /&gt;private void SessionCheck()&lt;br /&gt;{&lt;br /&gt;  if (Session.Count == 0)&lt;br /&gt;   {&lt;br /&gt;     Response.Redirect("~/login.aspx");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-646480670818031609?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/646480670818031609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=646480670818031609' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/646480670818031609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/646480670818031609'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/how-to-expire-web-page-immediately.html' title='How to expire a web page immediately?'/><author><name>.NET team</name><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-2557049885090666521.post-7642599297710833041</id><published>2008-03-10T17:08:00.000+05:30</published><updated>2008-12-11T19:07:14.690+05:30</updated><title type='text'>3-tire architecture using c# and asp.net</title><content type='html'>&lt;div&gt;&lt;span style="font-family:verdana;"&gt;In the pure 3-tier / N-tier model, the application is divided into three formal tiers: the presentation tier (or GUI layer), the middle tier (or application server) and the data tier. Figure 2 shows a 3-Tier / N-Tier architecture. The key addition in this model is an application server which encapsulates the application's business logic . N-tier is used to describe this architecture since the application server may be implemented in one or more layers and it may be distributed in one or more places. For simplicity, the architecture will simply be referred to as "3-Tier", rather than N-Tier.&lt;/span&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_dTCM5Vgc40g/R9UlCTRa1LI/AAAAAAAAAY4/8YaRDMy-Ukw/s1600-h/Build3tierApp4.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5176084068195554482" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R9UlCTRa1LI/AAAAAAAAAY4/8YaRDMy-Ukw/s320/Build3tierApp4.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Presentation Tier&lt;/strong&gt;&lt;br /&gt;The presentation tier can include a variety of clients including standard clients (as part of a client/server application), Internet clients and reporting tools. Because business logic is implemented in the middle tier, there is relatively little duplicated effort should there be a need to provide the same function in two or more environments. For example, an Order details screen might be provided in both a client/server application and the Internet application while any business logic in the middle tier (application server) would be shared.&lt;br /&gt;The presentation tier requests services from the application server but it is not limited to GUI clients. Items in the "top" tier might also include other applications that need to exchange information or data with this application.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Middle Tier (Application Server)&lt;/strong&gt;&lt;br /&gt;As mentioned earlier, the middle tier or application server might be implemented as several layers. Application servers can also be distributed on several host machines. A Transaction Processing (TP) monitor or an Object Request Broker (ORB) can be used to balance client requests across multiple database servers as well as start up/shutdown additional application server instances, as needed. Since the application server contains the business logic (where the bulk of the complex processing should occur), it is possible to support more users by adding more and faster application servers without needing to re-architect or rebuild the application.&lt;br /&gt;It is not necessary to physically locate the middle tier on its own server from the beginning. In an early application release (which has a limited number of users), the middle tier might be deployed on the client machine or on the database server for simplicity. When the number of users grow (e.g. for later releases), the middle tier can then be moved onto separate server(s) so that the desired scalability benefits are obtained.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Data Tier&lt;/strong&gt;&lt;br /&gt;The data tier contains the database. It might also include data access procedures. The database can be placed in a single location or it can be distributed, if required.&lt;br /&gt;&lt;strong&gt;The benefits of the 3-tier model are as follows: &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; The key 3-tier benefit is improved scalability since the application servers can be deployed on many machines. Also, the database no longer requires a connection from every client -- it only requires connections from a smaller number of application servers. In addition, TP monitors or ORBs can be used to balance loads and dynamically manage the number of application server(s) available. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Better Re-use:&lt;/strong&gt; The same logic can be initiated from many clients or applications. If an object standard like COM/DCOM or CORBA is employed (as discussed in &lt;/span&gt;&lt;a href="http://www.woodger.ca/archmult.htm#Tool_Dependence"&gt;&lt;span style="font-family:verdana;"&gt;tool dependence&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;), then the specific language implementation of the middle tier can be made transparent.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Improved Data Integrity:&lt;/strong&gt; since all updates go through the middle tier, the middle tier can ensure that only valid data is allowed to be updated in the database and the risk of a rogue client application corrupting data is removed.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Improved Security:&lt;/strong&gt; Security is improved since it can be implemented at multiple levels (not just the database). Security can be granted on a service-by-service basis. Since the client does not have direct access to the database, it is more difficult for a client to obtain unauthorized data. Business logic is generally more secure since it is placed on a more secure central server.&lt;br /&gt;Reduced Distribution: Changes to business logic only need to be updated on the application servers and do not have to be distributed to all the clients.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Improved Availability:&lt;/strong&gt; mission-critical applications can make use of redundant application servers and redundant database servers. With redundant servers, it is possible to architect an application so that it can recover from network or server failures.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Hidden Database Structure: &lt;/strong&gt;since the actual structure of the database is hidden from the caller, it is possible that many database changes can be made transparently. Therefore, a service in the middle tier that exchanges information/data with other applications could retain its original interface while the underlying database structure was enhanced during a new application release. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;The drawbacks of the 3-tier model are as follows: &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Increased Complexity/Effort:&lt;/strong&gt; In general, it is more difficult to build a 3-tier application compared to a 2-tier application. The points of communication are doubled (client to middle tier to server, instead of simply client to server) and many handy productivity enhancements provided by client tools (e.g. Visual Basic, PowerBuilder, Delphi) will be foregone or their benefit will be reduced with a 3-tier architecture.&lt;br /&gt;&lt;strong&gt;Fewer Tools:&lt;/strong&gt; There are many more tools available for a 2-tier model (e.g. most reporting tools). It is likely that additional programming effort will be required to manage tasks that an automated tool might handle in a 2-tier environment. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:78%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7642599297710833041?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7642599297710833041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7642599297710833041' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7642599297710833041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7642599297710833041'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/3-tire-architecture-using-c-and-aspnet.html' title='3-tire architecture using c# and asp.net'/><author><name>.NET team</name><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://3.bp.blogspot.com/_dTCM5Vgc40g/R9UlCTRa1LI/AAAAAAAAAY4/8YaRDMy-Ukw/s72-c/Build3tierApp4.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-6737105037661406920</id><published>2008-03-10T16:39:00.000+05:30</published><updated>2008-03-10T17:08:35.695+05:30</updated><title type='text'>Store image in sqlserver using c# , asp.net</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Store image in Sqlserver using c# and asp.net&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;color:#ff6600;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Table Creation&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;Create Table Person&lt;br /&gt;(&lt;br /&gt;PersonID Int Identity,&lt;br /&gt;PersonEmail Varchar(255),&lt;br /&gt;PersonName Varchar(255),&lt;br /&gt;PersonSex Char(1),&lt;br /&gt;PersonDOB DateTime,&lt;br /&gt;PersonImage Image,&lt;br /&gt;PersonImageType Varchar(255)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:verdana;color:#ff6600;"&gt;Stoted Procedure&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Create Proc sp_person_isp&lt;br /&gt;@PersonEmail Varchar(255),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;@PersonName Varchar(255),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;@PersonSex Char(1),&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;@PersonDOB DateTime,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;@PersonImage Image,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;@PersonImageType Varchar(255)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;As&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Begin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Insert into Person (PersonEmail, PersonName, PersonSex, PersonDOB, PersonImage, PersonImageType)Values(@PersonEmail, @PersonName, @PersonSex, @PersonDOB, @PersonImage, @PersonImageType)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;EndGo&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Code in the OnClick event of the Submit button.&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;Dim intImageSize As Int64&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Dim strImageType As String&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Dim ImageStream As Stream&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;' Gets the Size of the Image&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;intImageSize = PersonImage.PostedFile.ContentLength&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;' Gets the Image&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;TypestrImageType = PersonImage.PostedFile.ContentType&lt;br /&gt;' Reads the Image&lt;br /&gt;ImageStream = PersonImage.PostedFile.InputStream&lt;br /&gt;Dim ImageContent(intImageSize) As Byte&lt;br /&gt;Dim intStatus As Integer&lt;br /&gt;intStatus = ImageStream.Read(ImageContent, 0, intImageSize)&lt;br /&gt;' Create Instance of Connection and Command Object&lt;br /&gt;Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))&lt;br /&gt;Dim myCommand As New SqlCommand("sp_person_isp", myConnection)&lt;br /&gt;' Mark the Command as a SPROC&lt;br /&gt;myCommand.CommandType = CommandType.StoredProcedure&lt;br /&gt;' Add Parameters to SPROC&lt;br /&gt;Dim prmPersonImage As New SqlParameter("@PersonImage", SqlDbType.Image)prmPersonImage.Value = ImageContentmyCommand.Parameters.Add(prmPersonImage)&lt;br /&gt;Dim prmPersonImageType As New SqlParameter("@PersonImageType", SqlDbType.VarChar, 255)&lt;br /&gt;prmPersonImageType.Value = strImageTypemyCommand.Parameters.Add(prmPersonImageType)&lt;br /&gt;TrymyConnection.Open()&lt;br /&gt;myCommand.ExecuteNonQuery()&lt;br /&gt;myConnection.Close()&lt;br /&gt;Response.Write("New person successfully added!")&lt;br /&gt;Catch SQLexc As SqlException&lt;br /&gt;Response.Write("Insert Failed. Error Details are: " &amp;amp; SQLexc.ToString())&lt;br /&gt;End Try&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-6737105037661406920?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6737105037661406920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6737105037661406920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6737105037661406920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6737105037661406920'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/store-image-in-sqlserver-using-c-aspnet.html' title='Store image in sqlserver using c# , asp.net'/><author><name>.NET team</name><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-2557049885090666521.post-6984765115937767016</id><published>2008-03-10T16:35:00.001+05:30</published><updated>2008-03-10T16:39:00.497+05:30</updated><title type='text'>Export GridData to Excel</title><content type='html'>&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;color:#333333;"&gt;&lt;strong&gt;Export data from Datagrid to Excel&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;private void btnExportToExcel_Click(object sender,System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;ExportToExcel("Report.xls",DataGrid1);&lt;br /&gt;}&lt;br /&gt;private void ExportToExcel(string strFileName,DataGrid dg)&lt;br /&gt;{&lt;br /&gt;Response.Clear();&lt;br /&gt;Response.Buffer = true;Response.ContentType = "application/vnd.ms-excel";&lt;br /&gt;Response.AddHeader("content-disposition","attachment;filename=" + strFileName);&lt;br /&gt;Response.Charset = "";&lt;br /&gt;this.EnableViewState = false;&lt;br /&gt;System.IO.StringWriter sw = new StringWriter();&lt;br /&gt;System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);&lt;br /&gt;dg.RenderControl(htw);&lt;br /&gt;Response.Write(sw.ToString());&lt;br /&gt;Response.End();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style="font-size:78%;"&gt;Happy Programming&lt;/span&gt;&lt;/em&gt;&lt;/strong&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/2557049885090666521-6984765115937767016?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6984765115937767016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6984765115937767016' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6984765115937767016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6984765115937767016'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/export-griddata-to-excel.html' title='Export GridData to Excel'/><author><name>.NET team</name><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-2557049885090666521.post-7721917329493530015</id><published>2008-03-10T14:21:00.000+05:30</published><updated>2008-03-10T14:23:17.528+05:30</updated><title type='text'>Silverlight 2 Beta 1 Now Available!</title><content type='html'>&lt;span style="font-family:verdana;"&gt;There are two new ASP.NET server controls that make it easy for developers to incorporate Silverlight content into ASP.NET Web applications. Developers can start by installing the &lt;/span&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E0BAE58E-9C0B-4090-A1DB-F134D9F095FD&amp;amp;displaylang=en"&gt;&lt;span style="font-family:verdana;"&gt;Microsoft Silverlight Tools Beta 1 for Visual Studio 2008&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, which includes the Silverlight 2 Beta 1 runtime, the SDK, and the add-on to Visual Studio 2008. Then discover how to use the new ASP.NET server controls, MediaPlayer control and the Silverlight control, by walking through the &lt;/span&gt;&lt;a href="http://quickstarts.asp.net/3-5-extensions/silverlight/default.aspx"&gt;&lt;span style="font-family:verdana;"&gt;quickstarts&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7721917329493530015?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7721917329493530015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7721917329493530015' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7721917329493530015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7721917329493530015'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/silverlight-2-beta-1-now-available.html' title='Silverlight 2 Beta 1 Now Available!'/><author><name>.NET team</name><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-2557049885090666521.post-8666387020697051173</id><published>2008-03-10T14:13:00.000+05:30</published><updated>2008-03-10T14:19:46.871+05:30</updated><title type='text'>protecting two different folders with forms authentication</title><content type='html'>&lt;span style="font-family:verdana;"&gt;The authorization? settings in web.config affect all files and subfoldersby default wiht the same settings. If you want to change the settings forta specific file or directory you can use the location element:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;configuration&lt;br /&gt;system.web&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;system.web&lt;br /&gt;location path="SomeSubDir"&lt;br /&gt;system.web&lt;br /&gt;authorization&lt;br /&gt;allow roles="Admin"&lt;br /&gt;deny users="*"&lt;br /&gt;authorization&lt;br /&gt;system.web&lt;br /&gt;location&lt;br /&gt;configuration&lt;br /&gt;&lt;span style="color:#666666;"&gt;use open and close angular brackets.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#666666;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;font-size:78%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-8666387020697051173?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/8666387020697051173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=8666387020697051173' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8666387020697051173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8666387020697051173'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/protecting-two-different-folders-with.html' title='protecting two different folders with forms authentication'/><author><name>.NET team</name><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-2557049885090666521.post-4610014968256033677</id><published>2008-03-10T12:34:00.000+05:30</published><updated>2008-03-10T14:07:02.944+05:30</updated><title type='text'>Forms Authentication in ASP.NET</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;ASP.NET Forms Authentication&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Forms Authentication is a system in which unauthenticated requests are redirected to a Web form where users are required to provide their credentials. Upon submitting the form, and being properly verified by your application, an authorization ticket is issued by your Web application in the form of a cookie. This authorization cookie contains the user's credentials or a key for reacquiring the user's identity (e.g. therefore making the identity persistent). In essence, Forms Authentication is a means for wrapping your Web application around your own login user interface and verification processes.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Forms Authentication Flow&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;A client generates a request for a protected resource (e.g. a secured page from your site).&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;IIS (Internet Information Server) receives the request. If the requesting client is authenticated by IIS, the user/client is passed on to the ASP.NET application. Note that if Anonymous Access is enabled, the client will be passed onto the ASP.NET application by default. Otherwise, Windows will prompt the user for credentials to access the server's resources. Also note that because the authentication mode in the ASP.NET application is set to Forms, IIS authentication cannot be used.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;If the client doesn't contain a valid authentication ticket/cookie, ASP.NET will redirect the user to the URL specified in the loginURL attribute of the Authentication tag in your web.config file. This URL should contain the login page for your application. At this URL, the user is prompted to enter their credentials to gain access to the secure resource.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;The client must provide credentials, which are then authenticated/processed by your ASP.NET application. Your ASP.NET application also determines the authorization level of the request, and, if the client is authorized to access the secure resource, an authentication ticket is finally distributed to the client. If authentication fails, the client is usually returned an Access Denied message.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;The client can then be redirected back to the originally-requested resource, which is now accessible, provided that the client has met the authentication and authorization prerequisites discussed above. Once the authorization ticket/cookie is set, all subsequent requests will be authenticated automatically until the client closes the browser or the session terminates. You can have the user's credentials persist over time by setting the authorization ticket/cookie expiration value to the date you desire to have the credentials persist through. After that date, the user will have to log in again.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;Setting Up Forms Authentication&lt;br /&gt;Let's take a look at the applicable settings to execute Forms Authentication. In general, setting up Forms Authentication involves just a few simple steps.&lt;br /&gt;1) Enable anonymous access in IIS. By default, anonymous users should be allowed to access your Web application. In rare cases, however, you may opt to layer an Integrated Windows OS security layer level with Forms authentication. We will discuss how to integrate this layer with anonymous access enabled in the article succeeding this one ("Part 2 (Integration w/ Active Directory)").&lt;br /&gt;2) Configure your Web application's web.config file to use Forms Authentication. Start by setting the authentication mode attribute to Forms, and denying access to anonymous users. The following example shows how this can be done in the web.config file for your Web application:&lt;br /&gt;Upon setting the authentication mode to Forms, you'll notice that we appended another child element. The Forms element has five attributes that implement your forms authentication configuration. The attributes and their descriptions are as follows :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Attribute and Description&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;name &lt;/strong&gt;&lt;br /&gt;This is the name of the HTTP cookie from which we will store our authentication ticket and information, respectively.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;loginURL&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;This is the URL from which your unauthenticated client will be redirected. In most scenarios, this would be your login page, where the client is required to provide their credentials for authentication.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;protection&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;This is used to set the method from which to protect your cookie data. The following valid values can be supplied:&lt;br /&gt;1) &lt;strong&gt;&lt;span style="color:#ff6600;"&gt;All:&lt;/span&gt;&lt;/strong&gt; Specifies to use both data validation and encryption to protect the cookie. Triple DES is used for encryption, if it is available and if the key is long enough (48 bytes). The All value is the default (and suggested) value.&lt;br /&gt;2) &lt;strong&gt;&lt;span style="color:#ff6600;"&gt;None:&lt;/span&gt;&lt;/strong&gt; Used for sites that are only using cookies for personalization and have weaker requirements for security. Both encryption and validation can be disabled. This is the most efficient performance wise, but must be used with caution.&lt;br /&gt;3) &lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Encryption:&lt;/strong&gt;&lt;/span&gt; Specifies that the cookie is encrypted using Triple DES or DES, but data validation is not done on the cookie. It's important to note that this type of cookie is subject to chosen plaintext attacks.&lt;br /&gt;4) &lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Validation&lt;/span&gt;&lt;/strong&gt;: Specifies to avoid encrypting the contents of the cookie, but validate that the cookie data has not been altered in transit. To create the cookie, the validation key is concatenated in a buffer with the cookie data and a MAC is computed/appended to the outgoing cookie.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;timeout&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;This is the amount of time (in integer minutes) that the cookie has until it expires. The default value for this attribute is 30 (thus expiring the cookie in 30 minutes).The value specified is a sliding value, meaning that the cookie will expire n minutes from the time the last request was received.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;path&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;This is the path to use for the issued cookie. The default value is set to "/" to avoid issues with mismatched case in paths. This is because browsers are case-sensitive when returning cookies.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;span style="font-family:verdana;"&gt;In our web.config file, it's also important to note the value we have for the deny child element of the authorization section (as highlighted below). Essentially, we set that value of the users attribute to "?" to deny all anonymous users, thus redirecting unauthenticated clients to the loginURL.&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;&lt;configuration&gt;&lt;system.web&gt;&lt;authentication mode="Forms"&gt;&lt;forms path="/" timeout="30" protection="All" loginurl="login.aspx" name=".COOKIEDEMO"&gt;&lt;/authentication&gt;&lt;authorization&gt;&lt;deny users="?"&gt;&lt;/authorization&gt;&lt;/SYSTEM.WEB&gt;&lt;/configuration&gt;&lt;em&gt;&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&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/2557049885090666521-4610014968256033677?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4610014968256033677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4610014968256033677' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4610014968256033677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4610014968256033677'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/forms-authentication-in-aspnet.html' title='Forms Authentication in ASP.NET'/><author><name>.NET team</name><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-2557049885090666521.post-6383520118112779972</id><published>2008-03-07T16:44:00.000+05:30</published><updated>2008-03-07T16:58:41.173+05:30</updated><title type='text'>C# 3.0 Features: Extension Methods</title><content type='html'>&lt;span style="font-family:verdana;"&gt;NET 3.5 is out which means all of the great features available in C# 3.0 are available to use now. Here's a quick list of the main language enhancements available in C# 3.0:&lt;br /&gt;&lt;/span&gt;&lt;a href="http://newcsharp.blogspot.com/2008/03/c-30-features-object-initializers.html" target="_blank"&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Object Initializers&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://newcsharp.blogspot.com/2008/03/c-30-features-automatic-properties.html" target="_blank"&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Automatic Properties&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Extension Methods&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Anonymous Types&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Lambda Expressions&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;LINQ&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Collection Initializers&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Extension methods allow existing classes to be extended without relying on inheritance or having to change the class's source code. This means that if you want to add some methods into the existing String class you can do it quite easily. Here's a couple of rules to consider when deciding on whether or not to use extension methods:&lt;br /&gt;&lt;/span&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Extension methods cannot be used to override existing methods&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;An extension method with the same name and signature as an instance method will not be called&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;The concept of extension methods cannot be applied to fields, properties or events&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Use extension methods sparingly....overuse can be a bad thing!&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Here's an example of creating an extension method in C# that adds a RemoveNonNumeric() method to the String class.  Notice that the class is defined as static as well as the extension method itself.  The "this" keyword in the parameter signature tells the compiler to add the extension method to the String class since "string" follows the keyword. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;namespace StringExtensions&lt;br /&gt;{&lt;br /&gt;    public static class StringExtensionsClass&lt;br /&gt;    {&lt;br /&gt;       public static string RemoveNonNumeric(this string s)&lt;br /&gt;       {&lt;br /&gt;            MatchCollection col = Regex.Matches(s, "[0-9]");&lt;br /&gt;            StringBuilder sb = new StringBuilder();&lt;br /&gt;            foreach (Match m in col)&lt;br /&gt;                sb.Append(m.Value);&lt;br /&gt;            return sb.ToString();&lt;br /&gt;        }&lt;br /&gt;    }&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Here's an example of how the extension method can be used.  You'll see that the namespace for the extension method class is imported.  From there, the compiler treats the RemoveNonNumeric() method as if it was originally part of the standard System.String class. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;using StringExtensions;&lt;br /&gt;....&lt;br /&gt;string phone = "123-123-1234";&lt;br /&gt;string newPhone = phone.RemoveNonNumeric();&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Update:  Although the overall point of the post was to simply show how to create extension methods, Andrex posted a more efficient way to remove non-numeric characters for those that may actually need that specific functionality (I'll admit I was just throwing something out there :-)).  Thanks for commenting Andrex!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public static string RemoveNonNumeric(this string s)&lt;br /&gt;{&lt;br /&gt;StringBuilder sb = new StringBuilder();&lt;br /&gt;for (int i = 0; i &lt; s.Length; i++)&lt;br /&gt;if (Char.IsNumber(s[i]))&lt;br /&gt;sb.Append(s[i]);&lt;br /&gt;return sb.ToString();&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Update 2:  Richard posted the following method which is potentially even faster according to his tests.  We're kind of pulling hairs here, but it's useful for "anyone who agonizes over every wasted millisecond" as he mentions in the comments (I'm not one of those people :-)).  I'm thinking I should start a "How would you refactor this code" series.  Could be kind of fun.  :-)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public static string RemoveNonNumeric(this string s)&lt;br /&gt;{&lt;br /&gt;if (!string.IsNullOrEmpty(s))&lt;br /&gt;{&lt;br /&gt;char[] result = new char[s.Length];&lt;br /&gt;int resultIndex = 0;&lt;br /&gt;foreach (char c in s)&lt;br /&gt;{&lt;br /&gt;if (char.IsNumber(c))&lt;br /&gt;result[resultIndex++] = c;&lt;br /&gt;}&lt;br /&gt;if (0 == resultIndex)&lt;br /&gt;s = string.Empty;&lt;br /&gt;else if (result.Length != resultIndex)&lt;br /&gt;s = new string(result, 0, resultIndex);&lt;br /&gt;}&lt;br /&gt;return s;&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:78%;color:#ff6600;"&gt;&lt;strong&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/strong&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/2557049885090666521-6383520118112779972?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6383520118112779972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6383520118112779972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6383520118112779972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6383520118112779972'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/c-30-features-extension-methods.html' title='C# 3.0 Features: Extension Methods'/><author><name>.NET team</name><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-2557049885090666521.post-7163037395894104757</id><published>2008-03-07T15:30:00.001+05:30</published><updated>2008-03-07T16:39:22.240+05:30</updated><title type='text'>C# 3.0 Features: Automatic Properties</title><content type='html'>&lt;span style="font-family:verdana;"&gt;NET 3.5 is out which means all of the great features available in C# 3.0 are available to use now. Here's a quick list of the main language enhancements available in C# 3.0:&lt;br /&gt;&lt;/span&gt;&lt;a class="" href="http://newcsharp.blogspot.com/2008/03/c-30-features-object-initializers.html" target="_blank" mce_href="http://newcsharp.blogspot.com/2008/03/c-30-features-object-initializers.html"&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Object Initializers&lt;/span&gt;&lt;/li&gt;&lt;/a&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Automatic Properties&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Anonymous Types&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Extension Methods&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Lambda Expressions&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;LINQ&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Collection Initializers&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;One of the things I can't say that I've enjoyed doing in the past when writing .NET classes was creating properties and associated fields. I leveraged the "prop" code snippet a lot in Visual Studio 2005 so that I didn't have to type much, but I still had to go through and define the field name and property name in the code. While public fields could certainly be used in some cases, they don't provide any control over the data being assigned (especially if the field is a string type) and aren't supported well when it comes to data binding. As a result I always create public properties to wrap fields even if I don't have any "extra" logic that needs added into the get or set blocks. Here's the standard way of creating fields and properties using C# 2.0:&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public class Person &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;string _FirstName;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;string _LastName; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public string FirstName &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{ &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;get &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;return _FirstName; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;set&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;_FirstName = value; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public string LastName&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;get &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;return _LastName;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;} &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;set&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;_LastName = value; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;"&gt;With C# 3.0 a new feature called "automatic properties" is now available. When you use the "prop" code snippet in Visual Studio 2008 you'll see that empty get and set blocks are added and that no associated field is added into the code. The compiler will automatically generate the backing field at compile time if it finds empty get or set blocks saving you the work. You can still add get and set blocks that have additional filtering logic in them as well although you'll have to type all of that yourself of course.&lt;br /&gt;Here's an example of how properties can be written in C# 3.0....you gotta love it especially when you compare how much more compact this technique is compared to the older way of doing things.&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public class Person&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public string FirstName { get; set; }&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;public string LastName { get; set; }&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;} &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;strong&gt;&lt;span style="font-family:Verdana;font-size:78%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7163037395894104757?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7163037395894104757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7163037395894104757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7163037395894104757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7163037395894104757'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/c-30-features-automatic-properties.html' title='C# 3.0 Features: Automatic Properties'/><author><name>.NET team</name><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-2557049885090666521.post-568015085770705999</id><published>2008-03-07T15:19:00.000+05:30</published><updated>2008-03-07T15:28:05.678+05:30</updated><title type='text'>C# 3.0 Features: Object Initializers</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Many of the new features rely on the compiler to generate code that you would have had to write in the past. This can result in significantly less code compared to C# 2.0 syntax in many cases. Here's a list of some of the key features available in C# 3.0:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Object Initializers&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Anonymous Types&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Automatic Properties&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Extension Methods&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Lambda Expressions&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;LINQ&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Collection Initializers&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;In this post I'll discuss the fundamentals of object initializers in C# 3.0.  To get started, let's look at the standard way of initializing an object with data in C# 2.0 using constructors.  The following example creates a Person object and passes three values to its constructor.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;Person p = new Person("John", "Doe", "602-123-1234");&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;As mentioned, C# 3.0 now supports the concept of "object initializers" which means you can easily assign data to specific properties in a type with having to create an explicit constructor (you can of course still create constructors as well). The standard C# { and } brackets are used to create object initializers.  Here's an example of using an object initializer to assign property data to a Person type.  It's nice because doing the same thing without using a constructor in C# 2.0 would have resulted in around 5 lines of code which is too many for something simple like property value assignments.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;Person p = new Person() {FirstName="John",LastName="Doe",Phone="602-123-1234",City="Phoenix"};&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;If the Person type defines a sub object as a property you can even use object initializers to create the sub object. Here's an example of defining an Address object:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;Person p = new Person()&lt;br /&gt;{&lt;br /&gt;FirstName = "John",&lt;br /&gt;LastName = "Doe",&lt;br /&gt;Address = new Address()&lt;br /&gt;{&lt;br /&gt;Street = "1234 St.",&lt;br /&gt;City = "Phoenix"&lt;br /&gt;}&lt;br /&gt;};&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;If you've used JavaScript Object Notation (normally referred to as JSON) in AJAX or other client-side applications, you'll recognize this style of syntax.  It's simple, compact, and easy to use. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;&lt;em&gt;Happy Programming&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&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/2557049885090666521-568015085770705999?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/568015085770705999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=568015085770705999' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/568015085770705999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/568015085770705999'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/c-30-features-object-initializers.html' title='C# 3.0 Features: Object Initializers'/><author><name>.NET team</name><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-2557049885090666521.post-8333977827702157123</id><published>2008-03-07T12:26:00.000+05:30</published><updated>2008-03-07T12:31:27.554+05:30</updated><title type='text'>AJAX Control Toolkit for Visual Studio 2008 and .NET 3.5 Released - 3.0.20229</title><content type='html'>&lt;span style="font-family:verdana;"&gt;A new version of the AJAX Control Toolkit, v3.0.20229, has been released and is the official release for Visual Studio 2008 and the .NET 3.5 Framework. It includes a number of bug fixes and the following major fixes:&lt;br /&gt;&lt;/span&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;ValidatorCallout supports styling the popup using CSS and server-side validation.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;ListSearch has enabled the options of searching for sub-strings in the list items and clearing the search query if no match is found.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;AutoComplete only queries for matches when the user types a character.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;You can &lt;/span&gt;&lt;a href="http://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=11121" target="_blank"&gt;&lt;span style="font-family:verdana;"&gt;download&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; the AJAX Control Toolkit on CodePlex. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-8333977827702157123?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/8333977827702157123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=8333977827702157123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8333977827702157123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8333977827702157123'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/ajax-control-toolkit-for-visual-studio.html' title='AJAX Control Toolkit for Visual Studio 2008 and .NET 3.5 Released - 3.0.20229'/><author><name>.NET team</name><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-2557049885090666521.post-4212729785204029887</id><published>2008-03-07T11:48:00.000+05:30</published><updated>2008-03-07T11:56:13.379+05:30</updated><title type='text'>new features in C# 3.0</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family:verdana;font-size:130%;color:#ff6600;"&gt;Extension methods in C# 3.0&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;One of the new features coming in C# 3.0 is Extension Methods. Quoting from LINQ for Visual C# 2005:&lt;br /&gt;&lt;/strong&gt;"As the name implies, extension methods extend existing .NET types with new methods."&lt;br /&gt;Extension methods sound like a last resort form of extensibility since they are apparently hard to discover in the code, but nonetheless the idea is cool and could come in handy in the future. Obviously LINQ is handy :)&lt;br /&gt;Most of the examples I have seen pick on the string class, so I won't take this time to be original. Here is an example of adding an IsValidEmailAddress method onto an instance of a string class:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;font-size:85%;color:#ff6600;"&gt;&lt;strong&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;string customerEmailAddress = "test@test.com";&lt;br /&gt;if (customerEmailAddress.IsValidEmailAddress())&lt;br /&gt;{&lt;br /&gt;// Do Something...&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public static class Extensions&lt;br /&gt;{&lt;br /&gt;public static bool IsValidEmailAddress(this string s)&lt;br /&gt;{&lt;br /&gt;Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$");&lt;br /&gt;return regex.IsMatch(s);&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;The extension methods need to be static methods in a static class within a namespace that is in scope as shown above. The this keyword in front of the parameter string s makes this an extension method.&lt;br /&gt;String.IsNullOrEmpty&lt;br /&gt;One of the coolest things I love about the new string class in .NET 2.0 is the addition of the IsNullOrEmpty method. Now if that wasn't in there, we could do it with Extension Methods. In fact, since IsNullOrEmpty is currently a static method, we can go ahead and add the extension method anyway since it works on class instances. Let's go crazy and have it call Trim(), too :)&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;&lt;/span&gt;&lt;span style="font-size:85%;color:#ff6600;"&gt;class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;string newString = null;&lt;br /&gt;if (newString.IsNullOrEmpty())&lt;br /&gt;{&lt;br /&gt;// Do Something&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public static class Extensions&lt;br /&gt;{&lt;br /&gt;public static bool IsNullOrEmpty(this string s)&lt;br /&gt;{&lt;br /&gt;// Notice I trim it too :)&lt;br /&gt;return (s == null s.Trim().Length == 0);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:78%;color:#ff6600;"&gt;&lt;em&gt;&lt;strong&gt;Happy Programming&lt;/strong&gt;&lt;/em&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/2557049885090666521-4212729785204029887?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4212729785204029887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4212729785204029887' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4212729785204029887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4212729785204029887'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/03/new-features-in-c-30.html' title='new features in C# 3.0'/><author><name>.NET team</name><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-2557049885090666521.post-8335451596694601049</id><published>2008-02-29T16:40:00.000+05:30</published><updated>2008-02-29T18:14:30.527+05:30</updated><title type='text'>Registering an Assembly in the GAC</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;Registering an Assembly in the GAC&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1)&lt;/strong&gt; Create an assembly key file Use the sn.exe tool to create a key file: sn -k StrongNameFile.snk If your path environment variables aren't set, you'll have to go to the C:\Program Files\Microsoft.NET\FrameworkSDK\Bin\ directory to run sn.exe) The filename "StrongNameFile.snk" can be any name you want.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;strong&gt;2)&lt;/strong&gt; Edit your assembly Now you have to add a tag which will link your assembly key to the assembly: using System.Reflection; [assembly:AssemblyKeyFile("StrongNameFile.snk")] Normally this is done in the utility AssemblyInfo.cs (vb) file.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3) &lt;/strong&gt;Add your assembly to the GAC gacutil /i AssemblyFileName.dll To uninstall this assembly from the GAC, use the command: gacutil /u AssemblyFileName&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4)&lt;/strong&gt; (Opional) Add your assembly to machine.config Locate the &lt;assemblies&gt; tag (for web apps,under &lt;configuration&gt;/&lt;system.web&gt;/&lt;compilation&gt;/&lt;compilers&gt;/&lt;assemblies&gt;) Between the &lt;assemblies&gt; tags, enter: &lt;add assembly="AssemblyFileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=5edf592a9c40680c"&gt; You can get the information for the assembly attribute, by running the gacutil /l command which will return a list of all the assemblies in the GAC. You will have to look for the one you just added and copy the entire line (less the Custom=XXX part at the end). At this point, you will be able to place this directive in your aspx pages. &lt;%@Import Namespace="YourNamespace"%&gt; or, you can set a reference in the Visual Studio IDE as you would with other GAC Assemblies.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff6600;"&gt;Happy Programming&lt;/span&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-8335451596694601049?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/8335451596694601049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=8335451596694601049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8335451596694601049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8335451596694601049'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/registering-assembly-in-gac.html' title='Registering an Assembly in the GAC'/><author><name>.NET team</name><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-2557049885090666521.post-8692528806179499120</id><published>2008-02-29T16:00:00.000+05:30</published><updated>2008-02-29T16:37:19.885+05:30</updated><title type='text'>regasm.exe, regsvr32.exe,tlbimp.exe and tlbexp.exe</title><content type='html'>&lt;strong&gt;&lt;span style="font-size:130%;color:#ff6600;"&gt;difference among regasm.exe, regsvr32.exe,tlbimp.exe and tlbexp.exe&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;The difference between regasm and regsvr32:&lt;br /&gt;&lt;/strong&gt;regasm.exe is used for registering an assembly so that a com client can access its classes and uses them like a com class.&lt;br /&gt;regasm.exe is used to create COM Callable Wrapper (CCW) around .NET assemblies. .NET managed assemblies(EXEs, DLLs) are different from COM DLLs (which are unmanaged, ie. they interact with the OS directly). So to register an unmanaged DLL we use regsvr32.exe.&lt;br /&gt;But if wehave a managed .NET assembly and we want to use it with COM components to use it as if it were a COM assembly, then we need to use regasm.exe.&lt;br /&gt;Regasm.exe creates a type library as well as registers it whereas &lt;strong&gt;tlbexp.exe&lt;/strong&gt; only creates a CCW but does not register it.&lt;br /&gt;&lt;strong&gt;Tlbimp.exe:&lt;/strong&gt;&lt;br /&gt;Tlbimp.exe (Type Library Importer) is used to create a Runtime Callable Wrapper around a COM component so that the unmanaged COM library can be used in .NET.&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;When do we use Tlbimp and not regasm or regsvr32?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Tlbexp.exe generates a type library that contains definitions of the types defined in the assembly. Applications such as Visual Basic 6.0 can use the generated type library to bind to the .NET types defined in the assembly.&lt;br /&gt;The entire assembly is converted at once. You cannot use Tlbexp.exe to generate type information for a subset of the types defined in an assembly.&lt;br /&gt;You cannot use Tlbexp.exe to produce a type library from an assembly that was imported using the Type Library Importer (Tlbimp.exe). Instead, you should refer to the original type library that was imported with Tlbimp.exe. You can export a type library from an assembly that references assemblies that were imported using Tlbimp.exe.&lt;br /&gt;Tlbexp.exe generates a type library but does not register it. This is in contrast to the Assembly Registration tool (Regasm.exe), which both generates and registers a type library. To generate and register a type library with COM, use Regasm.exe.&lt;br /&gt;&lt;strong&gt;Type Library Importer&lt;/strong&gt;&lt;br /&gt;Tlbimp.exe performs conversions on an entire type library at one time. You cannot use the tool to generate type information for a subset of the types defined within a single type library.&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;em&gt;&lt;span style="color:#ff6600;"&gt;Happy Programming.&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-8692528806179499120?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/8692528806179499120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=8692528806179499120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8692528806179499120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/8692528806179499120'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/regasmexe-regsvr32exetlbimpexe-and.html' title='regasm.exe, regsvr32.exe,tlbimp.exe and tlbexp.exe'/><author><name>.NET team</name><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-2557049885090666521.post-1209582607308170872</id><published>2008-02-28T16:26:00.000+05:30</published><updated>2008-12-11T19:07:14.844+05:30</updated><title type='text'>FOREIGN KEY Constraints</title><content type='html'>&lt;font face="verdana"&gt;&lt;strong&gt;FOREIGN KEY Constraints&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;A foreign key (FK) is a column or combination of columns used to establish and enforce a link between the data in two tables. A link is created between two tables by adding the column or columns that hold one table's primary key values to the other table. This column becomes a foreign key in the second table.&lt;br /&gt;&lt;br /&gt;You can create a foreign key by defining a FOREIGN KEY constraint when you create or alter a table.&lt;br /&gt;&lt;br /&gt;For example, the titles table in the pubs database has a link to the publishers table because there is a logical relationship between books and publishers. The pub_id column in the titles table matches the primary key column of the publishers table. The pub_id column in the titles table is the foreign key to the publishers table. &lt;/font&gt;&lt;img id="BLOGGER_PHOTO_ID_5171998233699662850" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R8ag_bqdvAI/AAAAAAAAAYc/i7VabL4hLGM/s320/foreign.bmp" border="0" /&gt;&lt;br /&gt;&lt;div&gt;&lt;font face="verdana"&gt;A FOREIGN KEY constraint does not have to be linked only to a PRIMARY KEY constraint in another table; it can also be defined to reference the columns of a UNIQUE constraint in another table. A FOREIGN KEY constraint can contain null values; however, if any column of a composite FOREIGN KEY constraint contains null values, then verification of the FOREIGN KEY constraint will be skipped.&lt;br /&gt;Note A FOREIGN KEY constraint can reference columns in tables in the same database or within the same table (self-referencing tables), for example, an employee table that contains three columns: employee_number, employee_name, and manager_employee_number. Because the manager is an employee too, there is a foreign key relationship from the manager_employee_number column to the employee_number column.&lt;br /&gt;Although the primary purpose of a FOREIGN KEY constraint is to control the data that can be stored in the foreign key table, it also controls changes to data in the primary key table. For example, if the row for a publisher is deleted from the publishers table, and the publisher's ID is used for books in the titles table, the relational integrity between the two tables is broken; the deleted publisher's books are orphaned in the titles table without a link to the data in the publishers table. A FOREIGN KEY constraint prevents this situation. The constraint enforces referential integrity by ensuring that changes cannot be made to data in the primary key table if those changes invalidate the link to data in the foreign key table. If an attempt is made to delete the row in a primary key table or to change a primary key value, the action will fail if the deleted or changed primary key value corresponds to a value in the FOREIGN KEY constraint of another table. To change or delete a row in a FOREIGN KEY constraint successfully, you must first either delete the foreign key data in the foreign key table or change the foreign key data in the foreign key table, thereby linking the foreign key to different primary key data.&lt;br /&gt;A FOREIGN KEY constraint is a candidate for an index because:&lt;br /&gt;Changes to PRIMARY KEY constraints are checked with FOREIGN KEY constraints in related tables.&lt;br /&gt;Foreign key columns are often used in join criteria when the data from related tables is combined in queries by matching the column(s) in the FOREIGN KEY constraint of one table with the primary or unique key column(s) in the other table. An index allows Microsoft® SQL Server™ 2000 to find related data in the foreign key table quickly. However, creating this index is not a requirement. Data from two related tables can be combined even if no PRIMARY KEY or FOREIGN KEY constraints are defined between the tables, but a foreign key relationship between two tables indicates that the two tables have been optimized to be combined in a query that uses the keys as its criteria.&lt;br /&gt;&lt;/div&gt;&lt;/font&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-1209582607308170872?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1209582607308170872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1209582607308170872' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1209582607308170872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1209582607308170872'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/foreign-key-constraints.html' title='FOREIGN KEY Constraints'/><author><name>.NET team</name><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://3.bp.blogspot.com/_dTCM5Vgc40g/R8ag_bqdvAI/AAAAAAAAAYc/i7VabL4hLGM/s72-c/foreign.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-1346964064226918491</id><published>2008-02-22T16:35:00.000+05:30</published><updated>2008-12-11T19:07:14.893+05:30</updated><title type='text'>Enterprise Library and .Net 2.0</title><content type='html'>&lt;strong&gt;&lt;/strong&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Using Enterprise DAAB from ASP.NET 2.0 project&lt;br /&gt;Enterprise Library and .Net 2.0&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#ff0000;"&gt;Error parsing application configuration file at line 47. Type '{http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration}ReadOnlyConfigurationSectionData' is not found in Schema. Please correct before processeding. (You might rename the current web.config and add a new one.)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;I tossed up a quick example of using the &lt;/span&gt;&lt;a href="http://newcsharp.blogspot.com/"&gt;&lt;span style="font-family:verdana;"&gt;Enterprise Library Configuration Application Block&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; in your applications, and thought I would give an example of using the &lt;strong&gt;Cache Application Block&lt;/strong&gt; as well. In this case, I am actually using the two application blocks together so we can seem them side-by-side. As always, the code will run in &lt;/span&gt;&lt;a href="http://www.newcsharp.blogspot.com/" target="_blank"&gt;&lt;span style="font-family:verdana;"&gt;Snippet Compiler&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;, but you need to &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/entlib.asp" target="_blank"&gt;&lt;span style="font-family:verdana;"&gt;download and install the Enterprise Library&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; and move over the appropriate DLL's shown in the directory.&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;In this example, I am using the &lt;strong&gt;XML File Storage Provider&lt;/strong&gt; to save my configuration settings in my &lt;strong&gt;sitesettings.config&lt;/strong&gt; file and using the default storage provider for caching, called the &lt;strong&gt;NullBackingStore&lt;/strong&gt;, which stores the cache information into a Hashtable in memory.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;This time when I run the Enterprise Library Configuration tool I need to add both the &lt;strong&gt;Caching Application Block&lt;/strong&gt; and &lt;strong&gt;Configuration Application Block&lt;/strong&gt; to my application (shown below). I keep the default settings, but I do have to specify that &lt;strong&gt;sitesettings.config&lt;/strong&gt; will be the XML file to store my global application settings. If you don't do this, the application will toss an error reminding you to do so.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;At first I was a bit confused as to why there is an &lt;strong&gt;XML File Storage Provider&lt;/strong&gt; and &lt;strong&gt;XML Serializer Transformer&lt;/strong&gt; under &lt;strong&gt;cachingConfiguration&lt;/strong&gt;. I didn't add it. It turns out that there is a separate XML file, called by default &lt;strong&gt;cachingConfiguration.config&lt;/strong&gt;, created to store the caching configuration information. It specifies that I am using the &lt;strong&gt;NullBackingStore&lt;/strong&gt; as well as a few other settings.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;img id="BLOGGER_PHOTO_ID_5169767238707559410" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R76z6bqdu_I/AAAAAAAAAYU/oTYBnliqByA/s320/r_cacheblock.jpg" border="0" /&gt; &lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Here is the code that reads and writes to both the configuration file and cache for testing:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;fieldset&gt;&lt;legend&gt;Testing Application Blocks&lt;/legend&gt;&lt;pre&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="color:#000000;"&gt; System;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="color:#000000;"&gt; Microsoft.Practices.EnterpriseLibrary.Configuration;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt;&lt;span style="color:#000000;"&gt; Microsoft.Practices.EnterpriseLibrary.Caching;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="color:#000000;"&gt; SiteSettings&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;#region&lt;/span&gt;&lt;span style="color:#000000;"&gt; Private Members&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; _name;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; _url;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; _emailAddress;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;#endregion&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;#region&lt;/span&gt;&lt;span style="color:#000000;"&gt; Properties&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; Name&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="color:#000000;"&gt; { &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="color:#000000;"&gt; _name; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="color:#000000;"&gt; { _name &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; value; }&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:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; Url&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="color:#000000;"&gt; { &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="color:#000000;"&gt; _url; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="color:#000000;"&gt; { _url &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; value; }&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:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="color:#000000;"&gt; EmailAddress&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="color:#000000;"&gt; { &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="color:#000000;"&gt; _emailAddress; }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="color:#000000;"&gt; { _emailAddress &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; value; }&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:#0000ff;"&gt;#endregion&lt;/span&gt;&lt;span style="color:#000000;"&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:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="color:#000000;"&gt; TestClass&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="color:#000000;"&gt; Main()&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Create initial "siteSettings" object&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        SiteSettings siteSettings &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="color:#000000;"&gt; SiteSettings();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        siteSettings.Name &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;DavidHayden.com&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;        siteSettings.Url &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.davidhayden.com/&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;;&lt;br /&gt;&lt;br /&gt;        siteSettings.EmailAddress &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;nospam@nospam.com&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&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:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Save "siteSettings" to the XML config file&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        ConfigurationManager.WriteConfiguration(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, siteSettings);&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:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Retrieve settings from the XML config file&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        SiteSettings mySettings &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; ConfigurationManager.GetConfiguration(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;) &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;as&lt;/span&gt;&lt;span style="color:#000000;"&gt; SiteSettings;&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="color:#000000;"&gt; (mySettings &lt;/span&gt;&lt;span style="color:#000000;"&gt;!=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Name = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, mySettings.Name);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Url = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, mySettings.Url);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Email Address = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, mySettings.EmailAddress);&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&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:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Get the CacheManager&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        CacheManager myCacheManager &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; CacheFactory.GetCacheManager();&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:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Save the settings to the Cache&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        myCacheManager.Add(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;,mySettings);&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:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt; Retrieve settings from the cache&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        SiteSettings cachedSettings &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; (SiteSettings)myCacheManager.GetData(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;);&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="color:#000000;"&gt; (cachedSettings &lt;/span&gt;&lt;span style="color:#000000;"&gt;!=&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Name = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, cachedSettings.Name);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Url = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, cachedSettings.Url);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Email Address = {0}&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;, cachedSettings.EmailAddress);&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/fieldset&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;Although the configuration settings might be a bit ugly in the backend, the code is pretty straight forward. I have added comments above so you can see what is happening. Here are the configuration files:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;fieldset style="WIDTH: 701px; HEIGHT: 1184px"&gt;&lt;legend&gt;cachetest.exe.config&lt;/legend&gt;&lt;pre&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;section name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;enterpriselibrary.configurationSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Microsoft.Practices.EnterpriseLibrary.Configuration.&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        ConfigurationManagerSectionHandler,&lt;br /&gt;&lt;br /&gt;        Microsoft.Practices.EnterpriseLibrary.Configuration,&lt;br /&gt;&lt;br /&gt;        Version&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;1.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;0.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;, Culture&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;neutral, PublicKeyToken&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt; /&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;configSections&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;enterpriselibrary.configurationSettings&lt;br /&gt;&lt;br /&gt;        xmlns:xsd&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        xmlns:xsi&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        applicationName&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;EntLibTest&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        xmlns&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSections&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSection xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;ReadOnlyConfigurationSectionData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;cachingConfiguration&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; encrypt&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;false&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;storageProvider xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XmlFileStorageProviderData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XML File Storage Provider&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; path&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;cachingConfiguration.config&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;dataTransformer xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XmlSerializerTransformerData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Xml Serializer Transformer&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;includeTypes &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;dataTransformer&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSection&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSection name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; encrypt&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;false&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;storageProvider xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XmlFileStorageProviderData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XML File Storage Provider&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; path&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;sitesettings.config&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;dataTransformer xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;XmlSerializerTransformerData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Xml Serializer Transformer&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;includeTypes &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;dataTransformer&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSection&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;configurationSections&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;keyAlgorithmStorageProvider xsi:nil&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;true&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;includeTypes &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;enterpriselibrary.configurationSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/fieldset&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;fieldset style="WIDTH: 904px; HEIGHT: 725px"&gt;&lt;legend&gt;cacheConfiguration.config&lt;/legend&gt;&lt;pre&gt;&lt;span style="color:#000000;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#000000;"&gt;xml version&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;1.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; encoding&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;utf-8&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;cachingConfiguration&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;xmlSerializerSection type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;        Microsoft.Practices.EnterpriseLibrary.Caching, Version&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;1.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;0.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;, Culture&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;neutral, PublicKeyToken&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;enterpriseLibrary.cacheSettings xmlns:xsd&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            xmlns:xsi&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; defaultCacheManager&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Cache Manager&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            xmlns&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/cache&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheManagers&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheManager name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Cache Manager&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; expirationPollFrequencyInSeconds&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;60&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;                maximumElementsInCacheBeforeScavenging&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;1000&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; numberToRemoveWhenScavenging&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;10&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheStorage xsi:type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;CustomCacheStorageData&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; name&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Null Storage&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;                type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore,&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;                    Microsoft.Practices.EnterpriseLibrary.Caching, Version&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;1.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;.&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;0.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;, Culture&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;neutral,&lt;br /&gt;&lt;br /&gt;                    PublicKeyToken&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;            &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;extensions &lt;/span&gt;&lt;span style="color:#000000;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheStorage&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheManager&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;cacheManagers&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;enterpriseLibrary.cacheSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;xmlSerializerSection&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;cachingConfiguration&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/fieldset&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;fieldset style="width: 626px"&gt;&lt;legend&gt;sitesettings.config&lt;/legend&gt;&lt;pre&gt;&lt;span style="color:#000000;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#000000;"&gt;xml version&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;1.0&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt; encoding&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;utf-8&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;?&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;xmlSerializerSection type&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;SiteSettings, cachetest, Version=0.0.0.0,&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;            Culture&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;neutral, PublicKeyToken&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;SiteSettings xmlns:xsd&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;            xmlns:xsi&lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#008080;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;&lt;span style="color:#000000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;Name&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;DavidHayden.com&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;Name&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;Url&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;http:&lt;/span&gt;&lt;span style="color:#008000;"&gt;//&lt;/span&gt;&lt;span style="color:#008000;"&gt;www.davidhayden.com/&amp;lt;/Url&amp;gt;&lt;/span&gt;&lt;span style="color:#008000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;      &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;EmailAddress&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;nospam@nospam.com&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;EmailAddress&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;xmlSerializerSection&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#000000;"&gt;SiteSettings&lt;/span&gt;&lt;span style="color:#000000;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/fieldset&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:verdana;"&gt;As you can see, there is certainly a lot of flexiblity with the Enterprise Library as literally you could change the configuration in the backend to specify different storage providers and theoretically never change a single line of code. There has got to be some price to this flexiblity, which is a couple of XML files to specify settings. It looks a bit daunting at first if you aren't used to XML and the plug-in type architecture, but by playing with it more and more one can get comfortable with it pretty quickly.&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/2557049885090666521-1346964064226918491?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1346964064226918491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1346964064226918491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1346964064226918491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1346964064226918491'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/enterprise-library-and-net-20.html' title='Enterprise Library and .Net 2.0'/><author><name>.NET team</name><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://3.bp.blogspot.com/_dTCM5Vgc40g/R76z6bqdu_I/AAAAAAAAAYU/oTYBnliqByA/s72-c/r_cacheblock.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-4036165775377560864</id><published>2008-02-19T18:08:00.000+05:30</published><updated>2008-02-20T11:22:31.597+05:30</updated><title type='text'>What are delegates and why are they required?</title><content type='html'>&lt;span style="font-family:verdana;color:#ff6600;"&gt;&lt;strong&gt;Working with Delegates in C#&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style="color:#333333;"&gt;&lt;strong&gt;Introduction&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Delegates in C# are like functions pointers in C/C++. A multi cast delegate can refer to several methods. A delegate can be used to invoke a method, the call to which can only be resolved or determined at runtime. This article discusses what delegates are and how they can be used in C# with lucid code examples.&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;What are delegates and why are they required?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Delegates are function pointers in C# that are managed and type safe and can refer to one or more methods that have identical signatures. Delegates in C# are reference types. They are type safe, managed function pointers in C# that can be used to invoke a method that the delegate refers to. The signature of the delegate should be the same as the signature of the method to which it refers. According to MSDN, "A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. Unlike function pointers in C or C++, delegates are object-oriented, type-safe, and secure."&lt;br /&gt;C# provides support for Delegates through the class called Delegate in the System namespace. Delegates are of two types.&lt;br /&gt;&lt;strong&gt;Single-cast delegates&lt;br /&gt;Multi-cast delegates&lt;br /&gt;&lt;/strong&gt;A Single-cast delegate is one that can refer to a single method whereas a Multi-cast delegate can refer to and eventually fire off multiple methods that have the same signature.&lt;br /&gt;&lt;strong&gt;The signature of a delegate type comprises are the following.&lt;/strong&gt;&lt;br /&gt;The name of the delegate&lt;br /&gt;The arguments that the delegate would accept as parameters&lt;br /&gt;The return type of the delegate&lt;br /&gt;A delegate is either public or internal if no specifier is included in its signature. Further, you should instantiate a delegate prior to using the same.&lt;br /&gt;&lt;strong&gt;The following is an example of how a delegate is declared.&lt;/strong&gt;&lt;br /&gt;Listing 1:&lt;span style="color:#663333;"&gt; &lt;strong&gt;Declaring a delegate public delegate void TestDelegate(string message);&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;The return type of the delegate shown in the above example is "void" and it accepts a string argument. Note that the keyword "delegate" identifies the above declaration as a delegate to a method. This delegate can refer to and eventually invoke a method that can accept a string argument and has a return type of void, i.e., it does not return any value. You can use a delegate to make it refer to and invoke a method that has identical signature as the delegate only. Even if you are using multi-cast delegates, remember that you can use your delegate to refer to and then fire off multiple methods that have identical signatures only.&lt;br /&gt;A delegate should always be instantiated before it is used. The following statement in Listing 2 shows how you can instantiate a delegate.&lt;br /&gt;Listing 2: Instantiating a delegate&lt;br /&gt;&lt;span style="color:#663333;"&gt;&lt;strong&gt;TestDelegate t = new TestDelegate(Display);&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;Implementing Delegates in C#&lt;br /&gt;This section illustrates how we can implement and use delegates in C#. The following is an example of a delegate that is used to refer to a method of identical signature as the delegate and eventually invoke the method using the delegate.&lt;br /&gt;Listing 3: Implementing a single-cast delegate using System;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#663333;"&gt;&lt;strong&gt;public delegate void TestDelegate(string message); //Declare the delegate&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;public static void Display(string message)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("The string entered is : " + message);&lt;br /&gt;}&lt;br /&gt;static void Main()&lt;br /&gt;{&lt;br /&gt;TestDelegate t = new TestDelegate(Display); //Instantiate the delegate&lt;br /&gt;Console.WriteLine("Please enter a string");&lt;br /&gt;string message = Console.ReadLine();&lt;br /&gt;t(message); //Invoke the delegate&lt;br /&gt;Console.ReadLine();&lt;br /&gt;}&lt;br /&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Refer to the code in Listing 3 above. Note how the delegate has been instantiated. The delegate should be passed the method name as argument when instantiating it to indicate the method that it would be referring to. Further, note that the signature of the delegate "TestDelegate" and the method that it refers to, i.e., "Display", have identical signatures.&lt;br /&gt;You can also assign the references of multiple methods to a delegate and use it to invoke multiple methods. Such a delegate is called a multi-cast delegate as multiple method references are cast to it and then the delegate is used to invoke these methods. The following code example illustrates how a multi-cast delegate can be implemented and used.&lt;br /&gt;Listing 4: Implementing a multi-cast delegate using System;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#663333;"&gt;&lt;strong&gt;public delegate void TestDelegate();&lt;br /&gt;class Test&lt;br /&gt;{&lt;br /&gt;public static void Display1()&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("This is the first method");&lt;br /&gt;}&lt;br /&gt;public static void Display2()&lt;br /&gt;{&lt;br /&gt;Console.WriteLine("This is the second method");&lt;br /&gt;}&lt;br /&gt;static void Main()&lt;br /&gt;{&lt;br /&gt;TestDelegate t1 = new TestDelegate(Display1);&lt;br /&gt;TestDelegate t2 = new TestDelegate(Display2);&lt;br /&gt;t1 = t1 + t2; // Make t1 a multi-cast delegate&lt;br /&gt;t1(); //Invoke delegate&lt;br /&gt;Console.ReadLine();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;On execution of the above program shown in code Listing IV, the following message is displayed:&lt;br /&gt;&lt;/strong&gt;This is the first method&lt;br /&gt;This is the second method&lt;br /&gt;Note how we have used the delegate instance t1 as a multi-cast delegate by assigning the references of both t1 and t2 to it. &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/2557049885090666521-4036165775377560864?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4036165775377560864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4036165775377560864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4036165775377560864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4036165775377560864'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/what-are-delegates-and-why-are-they.html' title='What are delegates and why are they required?'/><author><name>.NET team</name><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-2557049885090666521.post-1688244917895678297</id><published>2008-02-19T17:26:00.000+05:30</published><updated>2008-02-20T11:28:51.645+05:30</updated><title type='text'>Examples on Delegates in C#</title><content type='html'>&lt;span style="color:#ff6600;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Delegates in C#&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;color:#333333;"&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#330000;"&gt;&lt;span style="font-family:verdana;"&gt;Delegate is type which holds the method(s) reference in an object. It is also reffered as a type safe function pointers.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Encapsulating the method's call from caller.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Effective use of Delegat improves the performance of application.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:verdana;"&gt;Used to call a method asynchronously.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Declaration:&lt;/strong&gt;&lt;br /&gt;public delegate type_of_delegate delegate_name()&lt;br /&gt;&lt;strong&gt;Example :&lt;/strong&gt; public delegate int mydelegate(int delvar1,int delvar2)&lt;br /&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br /&gt;you can use delegeate without parameter or with parameter list.&lt;br /&gt;you should follow the same syntax as in the method.&lt;br /&gt;(if you are reffering the method with two int parameters and int return type the delegate which you are declaring should be the same format.This is how it is reffered as type safe function pointer)&lt;br /&gt;Sample Program using Delegate :&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff9900;"&gt;&lt;span style="font-size:85%;color:#663333;"&gt;&lt;strong&gt;public delegate double Delegate_Prod(int a,int b);&lt;br /&gt;class Class1 {&lt;br /&gt;static double fn_Prodvalues(int val1,int val2) { return val1*val2; } static void Main(string[] args) {&lt;br /&gt;//Creating the Delegate Instance Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);&lt;br /&gt;Console.Write("Please Enter Values");&lt;br /&gt;int v1 = Int32.Parse(Console.ReadLine()); int v2 = Int32.Parse(Console.ReadLine());&lt;br /&gt;//use a delegate for processing&lt;br /&gt;double res = delObj(v1,v2); Console.WriteLine ("Result :"+res); Console.ReadLine();&lt;br /&gt;} }&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Explanation:&lt;br /&gt;Here I have used a small program which demonstrates the use of delegate.&lt;br /&gt;The delegate "Delegate_Prod" is declared with double return type and which accepts only two interger parameters.&lt;br /&gt;Inside the Class the method named fn_Prodvalues is defined with double return type and two integer parameters.(The delegate and method is having the same signature and parameters type)&lt;br /&gt;Inside the Main method the delegate instance is created and the function name is passed to the delegae instace as following.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#663333;"&gt;&lt;strong&gt;Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;After this we are accepting the two values from the user and passing those values to the delegate as we do using method .&lt;br /&gt;&lt;span style="color:#663300;"&gt;&lt;strong&gt;&lt;span style="font-size:85%;"&gt;delObj(v1,v2);&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;Here delegate object encapsulates the method functionalities and return the result as we specified in the method.&lt;br /&gt;Multicast DelegateIt is a Delegate which holds the reference of more than one methods.Multicast delegates must contain only methods that return void, else there is a run-time exception.&lt;br /&gt;Simple Program using Multicast Delegate&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;color:#663333;"&gt;&lt;strong&gt;delegate void Delegate_Multicast(int x, int y);&lt;br /&gt;Class Class2&lt;br /&gt;{static void Method1(int x, int y) { Console.WriteLine("You r in Method 1");}static void Method2(int x, int y) { Console.WriteLine("You r in Method 2");}public static void Main() { Delegate_Multicast func = new Delegate_Multicast(Method1);&lt;br /&gt;func += new Delegate_Multicast(Method2); func(1,2); // Method1 and Method2 are called func -= new Delegate_Multicast(Method1); func(2,3); // Only Method2 is called}&lt;br /&gt;}&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Explanation:&lt;br /&gt;&lt;/strong&gt;In the above example you can see that two methods are defined named method1 and method2 whchi takes two integer parameters and return type as void.&lt;br /&gt;In the main method the Delegate object is created using the following statement&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:85%;color:#663333;"&gt;Delegate_Multicast func = new Delegate_Multicast(Method1);&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;Then the Delegate is added using the += operator and removed using -= operator.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#ff6600;"&gt;&lt;span style="color:#330000;"&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/2557049885090666521-1688244917895678297?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1688244917895678297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1688244917895678297' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1688244917895678297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1688244917895678297'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/examples-on-delegates-in-c.html' title='Examples on Delegates in C#'/><author><name>.NET team</name><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-2557049885090666521.post-6840582557469832460</id><published>2008-02-19T16:46:00.000+05:30</published><updated>2008-12-11T19:07:15.531+05:30</updated><title type='text'>Delegates example in c#</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_dTCM5Vgc40g/R7vOy7qdu9I/AAAAAAAAAYE/64J_7Hu9M3s/s1600-h/feed-icon16x16.png"&gt;&lt;img id="BLOGGER_PHOTO_ID_5168952371742358482" style="CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R7vOy7qdu9I/AAAAAAAAAYE/64J_7Hu9M3s/s320/feed-icon16x16.png" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;Using a delegate to pass data between two forms&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family:verdana;color:#666666;"&gt;&lt;strong&gt;Introduction&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:verdana;"&gt;This code demonstrates how you can pass data from one form to another using a delegate. The advantage of using a delegate is that the form from which you want to send the data, doesn't need to know anything about the form that it's sending its data to. This way, you can reuse the same form in other forms or applications.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#666666;"&gt;&lt;strong&gt;Details&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;This is form 1. From this form we display form 2. And from form 2 we send a TextBox back to form 1.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5168652767708691378" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R7q-Trqdu7I/AAAAAAAAAX0/2aVptUii3fI/s320/form1.gif" border="0" /&gt;&lt;br /&gt;And the code for form 1:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: #ffcc99"&gt;&lt;br /&gt;&lt;span style="font-family:verdana;font-size:85%;color:#000000;"&gt;private void btnForm1_Click(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;// Create an instance of form 2&lt;br /&gt;Form2 form2 = new Form2();&lt;br /&gt;&lt;br /&gt;// Create an instance of the delegate&lt;br /&gt;form2.passControl = new Form2.PassControl(PassData);&lt;br /&gt;&lt;br /&gt;// Show form 2&lt;br /&gt;form2.Show();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void PassData(object sender)&lt;br /&gt;{&lt;br /&gt;// Set de text of the textbox to the value of the textbox of form 2&lt;br /&gt;txtForm1.Text = ((TextBox)sender).Text;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Form 2 sends the TextBox back to form 1:&lt;br /&gt;&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5168655533667630018" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_dTCM5Vgc40g/R7rA0rqdu8I/AAAAAAAAAX8/CLx-Mn8UUZA/s320/form2.gif" border="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="BACKGROUND: #ffcc99"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;public class Form2 : System.Windows.Forms.Form&lt;br /&gt;{&lt;br /&gt;// Define delegate&lt;br /&gt;public delegate void PassControl(object sender);&lt;br /&gt;&lt;br /&gt;// Create instance (null)&lt;br /&gt;public PassControl passControl;&lt;br /&gt;&lt;br /&gt;private void btnForm2_Click(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (passControl != null)&lt;br /&gt;{&lt;br /&gt;passControl(txtForm2);&lt;br /&gt;{&lt;br /&gt;this.Hide();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;Of course, using the delegate, you can not only send back the textbox, but other controls, variables or even the form itself, because they are all objects. I hope this is useful.&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;&lt;span style="color:#000000;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#ff6600;"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-6840582557469832460?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/6840582557469832460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=6840582557469832460' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6840582557469832460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/6840582557469832460'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/delegates-example-in-c.html' title='Delegates example in c#'/><author><name>.NET team</name><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/_dTCM5Vgc40g/R7vOy7qdu9I/AAAAAAAAAYE/64J_7Hu9M3s/s72-c/feed-icon16x16.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-7780003595428985861</id><published>2008-02-15T18:32:00.000+05:30</published><updated>2008-02-15T18:35:14.001+05:30</updated><title type='text'>Temporary Tables in Sqlserver2000</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Temporary Tables&lt;br /&gt;&lt;/strong&gt;The simple answer is yes you can. Let look at a simple CREATE TABLE statement: CREATE TABLE #Yaks (&lt;br /&gt;YakID int,&lt;br /&gt;YakName char(30) )&lt;br /&gt;You'll notice I prefixed the table with a pound sign (#). This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When I close this session, the table will be automatically dropped. You can treat this table just like any other table with a few exceptions. The only real major one is that you can't have foreign key constraints on a temporary table. The others are covered in &lt;/span&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms130214.aspx"&gt;&lt;span style="font-family:verdana;"&gt;Books Online&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;.&lt;br /&gt;&lt;strong&gt;Temporary tables are created in tempdb. If you run this query:&lt;/strong&gt; CREATE TABLE #Yaks (&lt;br /&gt;YakID int,&lt;br /&gt;YakName char(30) )&lt;br /&gt;select name&lt;br /&gt;from tempdb..sysobjects&lt;br /&gt;where name like '#yak%'&lt;br /&gt;drop table #yaks&lt;br /&gt;You'll get something like this: name&lt;br /&gt;------------------------------------------------------------------------------------&lt;br /&gt;#Yaks_________________________ . . . ___________________________________00000000001D&lt;br /&gt;(1 row(s) affected)&lt;br /&gt;except that I took about fifty underscores out to make it readable. SQL Server stores the object with a some type of unique number appended on the end of the name. It does all this for you automatically. You just have to refer to #Yaks in your code.&lt;br /&gt;If two different users both create a #Yaks table each will have their own copy of it. The exact same code will run properly on both connections. Any temporary table created inside a stored procedure is automatically dropped when the stored procedure finishes executing. If stored procedure A creates a temporary table and calls stored procedure B, then B will be able to use the temporary table that A created. It's generally considered good coding practice to explicitly drop every temporary table you create.  If you are running scripts through SQL Server Management Studio or Query Analyzer the temporary tables are kept until you explicitly drop them or until you close the session.&lt;br /&gt;Now let's get back to your question. The best way to use a temporary table is to create it and then fill it with data. This goes something like this:CREATE TABLE #TibetanYaks(&lt;br /&gt;YakID int,&lt;br /&gt;YakName char(30) )&lt;br /&gt;INSERT INTO #TibetanYaks (YakID, YakName)&lt;br /&gt;SELECT YakID, YakName&lt;br /&gt;FROM dbo.Yaks&lt;br /&gt;WHERE YakType = 'Tibetan'&lt;br /&gt;-- Do some stuff with the table&lt;br /&gt;drop table #TibetanYaks&lt;br /&gt;Obviously, this DBA knows their yaks as they're selecting the famed Tibetan yaks, the Cadillac of yaks. Temporary tables are usually pretty quick. Since you are creating and deleting them on the fly, they are usually only cached in memory.&lt;br /&gt;&lt;strong&gt;Table Variables&lt;/strong&gt;&lt;br /&gt;If you are using SQL Server 2000 or higher, you can take advantage of the new TABLE variable type. These are similar to temporary tables except with more flexibility and they always stay in memory.  The code above using a table variable might look like this:DECLARE @TibetanYaks TABLE (&lt;br /&gt;YakID int,&lt;br /&gt;YakName char(30) )&lt;br /&gt;INSERT INTO @TibetanYaks (YakID, YakName)&lt;br /&gt;SELECT YakID, YakName&lt;br /&gt;FROM dbo.Yaks&lt;br /&gt;WHERE YakType = 'Tibetan'&lt;br /&gt;-- Do some stuff with the table&lt;br /&gt;Table variables don't need to be dropped when you are done with them.&lt;br /&gt;Which to Use&lt;br /&gt;If you have less than 100 rows generally use a table variable.  Otherwise use  a temporary table.  This is because SQL Server won't create statistics on table variables.&lt;br /&gt;If you need to create indexes on it then you must use a temporary table.&lt;br /&gt;When using temporary tables always create them and create any indexes and then use them.  This will help reduce recompilations.  The impact of this is reduced starting in SQL Server 2005 but it's still a good idea.&lt;br /&gt;&lt;strong&gt;Answering the Question&lt;br /&gt;&lt;/strong&gt;And all this brings us back to your question.  The final answer to your question might look something like this: DECLARE @TibetanYaks TABLE (&lt;br /&gt;YakID int,&lt;br /&gt;YakName char(30) )&lt;br /&gt;INSERT INTO @TibetanYaks (YakID, YakName)&lt;br /&gt;SELECT YakID, YakName&lt;br /&gt;FROM dbo.Yaks&lt;br /&gt;WHERE YakType = 'Tibetan'&lt;br /&gt;UPDATE @TibetanYaks&lt;br /&gt;SET YakName = UPPER(YakName)&lt;br /&gt;SELECT *&lt;br /&gt;FROM @TibetanYaks&lt;br /&gt;&lt;strong&gt;Global Temporary Tables&lt;/strong&gt;&lt;br /&gt;You can also create global temporary tables. These are named with two pound signs. For example, ##YakHerders is a global temporary table. Global temporary tables are visible to all SQL Server connections. When you create one of these, all the users can see it.  These are rarely used in SQL Server.&lt;br /&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br /&gt;That shows you an example of creating a temporary table, modifying it, and returning the values to the calling program. I hope this gives you what you were looking for.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7780003595428985861?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7780003595428985861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7780003595428985861' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7780003595428985861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7780003595428985861'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/temporary-tables-in-sqlserver2000.html' title='Temporary Tables in Sqlserver2000'/><author><name>.NET team</name><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-2557049885090666521.post-5721395117775713000</id><published>2008-02-15T17:00:00.000+05:30</published><updated>2008-02-21T12:44:37.158+05:30</updated><title type='text'>Faqs on asp.net - part1</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;2.1 What is ASP.NET? &lt;/strong&gt;&lt;br /&gt;ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.&lt;br /&gt;For more details refer&lt;br /&gt;What is ASP.NET ASP.NET OverView&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.2 Why does my ASP.NET file have multiple &lt;form&gt;tag with runat=server?&lt;br /&gt;&lt;/strong&gt;This means that ASP.Net is not properly registered with IIS. .Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe&lt;br /&gt;use the command: aspnet_regiis.exe -u ---&gt; to uninstall current asp.net version. use the command: aspnet_regiis.exe -i ---&gt; to install current asp.net version.&lt;br /&gt;&lt;br /&gt;For Windows Server 2003, you must use aspnet_regiis -i -enable This is because of the "Web Service Extensions" feature in IIS 6&lt;br /&gt;(if you install VS.NET or the framework without IIS installed, and then go back in and install IIS afterwards, you have to re-register so that ASP.NET 'hooks' into IIS properly."&lt;br /&gt;&lt;strong&gt;2.3 How to find out what version of ASP.NET I am using on my machine?&lt;br /&gt;VB.NET &lt;/strong&gt;&lt;br /&gt;Response.Write(System.Environment.Version.ToString() )&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write(System.Environment.Version.ToString() );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.4 Is it possible to pass a querystring from an .asp page to aspx page?&lt;br /&gt;&lt;/strong&gt;Yes you can pass querystring from .asp to ASP.NET page .asp&lt;br /&gt;&lt;%response.redirect "webform1.aspx?id=11"%&gt;&lt;br /&gt;&lt;br /&gt;.aspxVB.NET&lt;br /&gt;Response.Write (Request("id").ToString ())&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write (Request["id"].ToString ());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.5 How to comment out ASP.NET Tags? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.6 What is a ViewState?&lt;br /&gt;&lt;/strong&gt;In classic ASP, when a form is submitted the form values are cleared. In some cases the form is submitted with huge information. In such cases if the server comes back with error, one has to re-enter correct information in the form. But submitting clears up all form values. This happens as the site does not maintain any state (ViewState).&lt;br /&gt;In ASP .NET, when the form is submitted the form reappears in the browser with all form values. This is because ASP .NET maintains your ViewState. ViewState is a state management technique built in ASP.NET. Its purpose is to keep the state of controls during subsequent postbacks by the same user. The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a control.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want to NOT maintain the ViewState, include the directive at the top of an .aspx page If you do not want to maintain Viewstate for any control add the attribute EnableViewState="false" to any control. For more details refer The ASP.NET View State&lt;br /&gt;&lt;strong&gt;2.7 Where can I get the details on Migration of existing projects using various technologies to ASP.NET? &lt;/strong&gt;&lt;br /&gt;Microsoft has designed Migration Assistants to help us convert existing pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration. Below are the Code Migration Assistants&lt;br /&gt;ASP to ASP.NET Migration Assistant PHP to ASP.NET Migration Assistant JSP to ASP.NET Migration Assistant Refer Migrating to ASP.Net&lt;br /&gt;&lt;strong&gt;2.8 What is the equivalent of date() and time() in ASP.NET?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;System.DateTime.Now.ToShortDateString() System.DateTime.Now.ToShortTimeString()&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;System.DateTime.Now.ToShortDateString(); System.DateTime.Now.ToShortTimeString();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.9 How to prevent a button from validating it's form? &lt;/strong&gt;&lt;br /&gt;Set the CauseValidation property of the button control to False&lt;br /&gt;&lt;strong&gt;2.10 How to get the IP address of the host accessing my site?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Response.Write (Request.UserHostAddress.ToString ())&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write (Request.UserHostAddress.ToString ());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.11 How to access the Parameters passed in via the URL? &lt;/strong&gt;&lt;br /&gt;Call the Request.QueryStringmethod passing in the key. The method will return the parameter value associated with that key. VB.NET&lt;br /&gt;Request.QueryString("id")&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Request.QueryString["id"];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.12 How to Set Focus to Web Form Controls By Using Client-Side Script?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Refer Sample IE Code&lt;br /&gt;&lt;strong&gt;2.13 How to display a Wait page while a query is running? &lt;/strong&gt;&lt;br /&gt;Refer Asynchronous Wait State Pattern in ASP.NET&lt;br /&gt;&lt;strong&gt;2.14 How to implement Form based Authentication in ASP.NET application?&lt;br /&gt;&lt;/strong&gt;For&lt;br /&gt;VB.NET C#&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.15 How to catch the 404 error in my web application and provide more useful information? &lt;/strong&gt;&lt;br /&gt;In the global.asax Application_error Event write the following code&lt;br /&gt;VB.NET&lt;br /&gt;Dim ex As Exception = Server.GetLastError().GetBaseException() If TypeOf ex Is System.IO.FileNotFoundException Then 'your code 'Response.Redirect("err404.aspx") Else 'your code End If&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Exception ex = Server.GetLastError().GetBaseException(); if (ex.GetType() == typeof(System.IO.FileNotFoundException)) { //your code Response.Redirect ("err404.aspx"); } else { //your code }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.16 Is there a method similar to Response.Redirect that will send variables to the destination page other than using a query string or the post method?&lt;br /&gt;&lt;/strong&gt;Server.Transfer preserves the current page context, so that in the target page you can extract values and such. However, it can have side effects; because Server.Transfer doesnt' go through the browser, the browser doesn't update its history and if the user clicks Back, they go to the page previous to the source page.&lt;br /&gt;Another way to pass values is to use something like a LinkButton. It posts back to the source page, where you can get the values you need, put them in Session, and then use Response.Redirect to transfer to the target page. (This does bounce off the browser.) In the target page you can read the Session values as required.&lt;br /&gt;Refer to Passing Values Between Web Forms Pages for more information.&lt;br /&gt;&lt;strong&gt;2.17 What are the differences between HTML versus Server Control?&lt;br /&gt;&lt;/strong&gt;Refer&lt;br /&gt;ASP.NET Server Controls Recommendations Introduction to ASP.NET Server Controls&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.18 How can I change the action of a form through code? &lt;/strong&gt;&lt;br /&gt;You can't change it. The action attribute is owned by ASP.NET. Handle Events and Transfer.&lt;br /&gt;For work around refer to Paul Wilson's Multiple Forms and Non-PostBack Forms - Solution&lt;br /&gt;&lt;strong&gt;2.19 Is there any control that allows user to select a time from a clock - in other words is there a clock control?&lt;br /&gt;&lt;/strong&gt;Peter Blum has developed some controls. Check out Peter's Date Package: TimeOfDayTextBox and DurationTextBox Controls&lt;br /&gt;&lt;strong&gt;2.20 How to Compare time?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim t1 As String = DateTime.Parse("3:30 PM").ToString("t") Dim t2 As String = DateTime.Now.ToString("t") If DateTime.Compare(DateTime.Parse(t1), DateTime.Parse(t2)) &lt;&gt; than " &amp;amp; t2.ToString()) End If&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;string t1 = DateTime.Parse("3:30 PM").ToString("t"); string t2 = DateTime.Now.ToString("t"); if (DateTime.Compare(DateTime.Parse (t1), DateTime.Parse (t2)) &lt;&gt; than " + t2.ToString()); }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.21 How To work with TimeSpan Class? &lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim adate As DateTime = DateTime.Parse("06/24/2003") Dim bdate As DateTime = DateTime.Parse("06/28/2003") Dim ts As New TimeSpan(bdate.Ticks - adate.Ticks) Response.Write(ts.TotalDays &amp;amp; "&lt;br /&gt;") Response.Write(ts.TotalHours &amp;amp; ":" &amp;amp; ts.TotalMinutes &amp;amp; ":" &amp;amp; ts.TotalSeconds &amp;amp; ":" &amp;amp; ts.TotalMilliseconds)&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;DateTime adate = DateTime.Parse("06/24/2003"); DateTime bdate = DateTime.Parse("06/28/2003"); TimeSpan ts = new TimeSpan (bdate.Ticks - adate.Ticks); Response.Write(ts.TotalDays.ToString () + "&lt;br /&gt;"); Response.Write(ts.TotalHours.ToString() + ":" + ts.TotalMinutes.ToString() + ":" + ts.TotalSeconds.ToString() + ":" + ts.TotalMilliseconds.ToString() );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.22 Where can I get information on Cookies in ASP.NET?&lt;br /&gt;&lt;/strong&gt;Refer Mike Pope's article Basics of Cookies in ASP.NET&lt;br /&gt;&lt;strong&gt;2.23 Does ASP.Net still recognize the global.asa file? &lt;/strong&gt;&lt;br /&gt;ASP.Net does not recognize the standard ASP global.asa file. Instead it uses a file named global.asax with the same - plus additional - functionality.&lt;br /&gt;&lt;strong&gt;2.24 How should I destroy my objects in ASP.Net?&lt;br /&gt;&lt;/strong&gt;ASP.Net actually has very solid internal garbage collection. So this is not an issue as it was in previous versions of Active Server Pages. Link to more information: &lt;gcconcurrent&gt;Element&lt;br /&gt;&lt;strong&gt;2.25 Are there resources online with tips on ASP to ASP.Net conversions? &lt;/strong&gt;&lt;br /&gt;Microsoft has desiged The ASP to ASP.NET Migration Assistant help us convert ASP pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.&lt;br /&gt;The following Code Migration Assistants are discussed in the link below.&lt;br /&gt;ASP to ASP.NET Migration Assistant PHP to ASP.NET Migration Assistant JSP to ASP.NET Migration Assistant Refer Migrating to ASP.Net Also refer:&lt;br /&gt;Microsoft's ASP to ASP.NET Code Migration Assistant John Peterson's article Microsoft's ASP to ASP.NET Migration Assistant Paolo Cavone's article From ASP to ASP.NET... Painlessly!&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.26 How do I publish my ASP.NET application to my ISP's web server?&lt;br /&gt;&lt;/strong&gt;Your ISP must first create an IIS application and apply the Front Page Server Extensions to it. Then in Visual Studio .NET, select the "Project Copy Project" menu. Then enter the URL and select the FrontPage web access method. The "Copy Project" feature copies all of the necessary files to your ISP's machine for your ASP.NET application to run.&lt;br /&gt;You can also FTP your files to your ISP web server. But you must know which files to upload. For more details refer PRB: Remote ASP.NET Projects Require IIS on the Client Computer or FrontPage Server Extensions on the Server Computer&lt;br /&gt;&lt;strong&gt;2.27 Why do i get error message "Could not load type" whenever I browse to my ASP.NET web site? &lt;/strong&gt;&lt;br /&gt;Your code-behind files for either your .aspx or the global.aspx page have not been complied. Use Visual Studio .NET's "Build Build Solution" menu, or run the command line compiler.&lt;br /&gt;For more details refer PRB: "Could not load type" error message when you browse to .aspx page&lt;br /&gt;&lt;strong&gt;2.28 Will the WebMatrix SqlDataSourceControl work with a MySQL connection?&lt;br /&gt;&lt;/strong&gt;SqlDataSourceControl lets you connect and work with MS SQL DB, while AccessDataSourceControl do the same thing but for MS Access DB. Therefore SqlDataSourceControl can't help you in your MySql connectivity .For Connectivity with MySql refer Accessing MySQL Database with ASP.NET&lt;br /&gt;&lt;strong&gt;2.29 Can I combine classic ASP and ASP.NET pages?&lt;/strong&gt;&lt;br /&gt;No. ASP pages can run in the same site as ASP.NET pages, but you can't mix in a page. Also ASP and ASP.NET won't share their session.&lt;br /&gt;&lt;strong&gt;2.30 What is the difference between src and Code-Behind?&lt;br /&gt;&lt;/strong&gt;Src attribute means you deploy the source code files and everything is compiled JIT (just-in-time) as needed. Many people prefer this since they don't have to manually worry about compiling and messing with dlls -- it just works. Of course, the source is now on the server, for anyone with access to the server -- but not just anyone on the web.&lt;br /&gt;CodeBehind attribute doesn't really "do" anything, its just a helper for VS.NET to associate the code file with the aspx file. This is necessary since VS.NET automates the pre-compiling that is harder by hand, and therefore the Src attribute is also gone. Now there is only a dll to deploy, no source, so it is certainly better protected, although its always decompilable even then.&lt;br /&gt;&lt;strong&gt;2.31 How can I get the value of input box with type hidden in code-behind? &lt;/strong&gt;&lt;br /&gt;You can set the runat= server for the hidden control and you can use ControlName.Value to get its value in CodeBehind file&lt;br /&gt;&lt;strong&gt;2.32 I have created a .NET user control page (.ascx) but I cannot compile and run it.&lt;/strong&gt;&lt;br /&gt;User control (ascx) can't be run on it own, but you can drag it onto any web page (aspx) and then run it.&lt;br /&gt;&lt;strong&gt;2.33 What is a .resx file?&lt;br /&gt;&lt;/strong&gt;The .resx resource file format consists of XML entries, which specify objects and strings inside XML tags. This is useful for localization. For more details refer Resources in .resx files&lt;br /&gt;&lt;strong&gt;2.34 Is it possible to use a style sheet class directly on a control instead of using inline or page-level formatting ?&lt;/strong&gt;&lt;br /&gt;Every WebControl derived control has a CssClass property which allows you to set it's format to a style sheet.&lt;br /&gt;&lt;strong&gt;2.35 Can I recieve both HTML markup for page and code in the ASP.NET web page's source code portion in the Web browser?&lt;br /&gt;&lt;/strong&gt;No. The Web browser receives only HTML markup. No source code or web control syntax is passed back to the web browser.&lt;br /&gt;&lt;strong&gt;2.36 Why can't I put where at the top of an ASPX file and write my server-side scripts in C ?&lt;/strong&gt;&lt;br /&gt;The parsers ASP.NET uses to extract code from ASPX files understand C#, Visual Basic.NET, and JScript.NET. You can write server-side scripts in any language supported by a .NET compiler.&lt;br /&gt;&lt;strong&gt;2.37 ASP pages that worked pefectly on Windows 2000 Server and IIS 5.0 do not work on Windows 2003 Server with IIS 6.0. ASP.NET pages work fine. Why?&lt;/strong&gt;&lt;br /&gt;Start -&gt; Settings -&gt; Control Panel -&gt; Administrative Tools -&gt; and double clicking IIS Manager. Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left&lt;br /&gt;&lt;strong&gt;2.38 Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?&lt;/strong&gt;&lt;br /&gt;Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.39 How to get URL without querystring?&lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim stringUri As String = "&lt;a href="http://www.funandtech.blogspot.com/?id=1&amp;amp;auid=16"&gt;http://www.funandtech.blogspot.com/?id=1&amp;amp;auid=16&lt;/a&gt;" Dim weburi As Uri = New Uri(stringUri) Dim query As String = weburi.Query Dim weburl As String = stringUri.Substring(0, stringUri.Length - query.Length) Response.Write(weburl)&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;string stringUri = "&lt;a href="http://www.funandtech.blogspot.com/?id=1&amp;amp;auid=16"&gt;http://www.funandtech.blogspot.com/?id=1&amp;amp;auid=16&lt;/a&gt;"; Uri weburi = new Uri(stringUri); string query = weburi.Query; string weburl = stringUri.Substring(0, stringUri.Length - query.Length); Response.Write (weburl);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.40 What is the best way to output only time and not Date? &lt;/strong&gt;&lt;br /&gt;Use DateTime as follows VB.NET&lt;br /&gt;Response.Write(DateTime.Now.ToString("hh:mm:ss"))&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write(DateTime.Now.ToString("hh:mm:ss"));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.41 Do I have to compile code if I am changing the content of my aspx.cs file?&lt;br /&gt;&lt;/strong&gt;Yes if you have used Codebehind="my.aspx.cs". Not if you used src="my.aspx.cs" in your page declaration.&lt;br /&gt;&lt;strong&gt;2.42 How to grab the referring URL?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Response.Write ( Request.UrlReferrer.ToString())&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write ( Request.UrlReferrer.ToString());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.43 My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.58 How to validate that a string is a valid date?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim blnValid As Boolean = False Try DateTime.Parse(MyString) blnValid = True Catch blnValid = False End Try&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;bool blnValid=false; try { DateTime.Parse(MyString); blnValid=true; } catch { blnValid=false; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.59 Are namespaces and Class names Case Sensitive? &lt;/strong&gt;&lt;br /&gt;Namespaces and Class names are case Sensitive. Namespaces imported using the @ Import Directive will cause an error if the correct case is not used.&lt;br /&gt;&lt;strong&gt;2.60 How to convert string to a DateTime and compare it with another DateTime?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim blntimeIsOk As Boolean = DateTime.Parse("15:00") &lt; blntimeisok =" (DateTime.Parse("&gt;2.61 How to get the url of page dynamically?&lt;br /&gt;Use Request.Url property&lt;br /&gt;&lt;strong&gt;2.62 How to convert user input in dMy format to Mdy? &lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim dt As DateTime = DateTime.ParseExact("0299", New String() {"My", "M/y"}, Nothing, System.Globalization.DateTimeStyles.None)&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;DateTime dt = DateTime.ParseExact("0299", new string[] {"My","M/y"}, null,System.Globalization.DateTimeStyles.None);&lt;br /&gt;&lt;br /&gt;For more details refer DateTime.ParseExact&lt;br /&gt;&lt;strong&gt;2.63 When the User is prompted a File Download dialogbox, if the user selects "Save" then the "Save as" dialog box is displayed. Is there any way for me to retrieve the filename and directory path specified by the user on the File Download dialog box?&lt;br /&gt;&lt;/strong&gt;Clients do not report information back about where the user selects to save the content, so there isn't an easy way to do this. Instead, you would need to ask the user before using the content-disposition for a file path, and then you could specify the filename parameter for the content-disposition header. Still, the user is free to change that path when actually downloading.&lt;br /&gt;&lt;strong&gt;2.64 How to hide or show Controls in server side code?&lt;br /&gt;&lt;/strong&gt;In any appropriate event write VB.NET&lt;br /&gt;TextBox1.Visible =not TextBox1.Visible&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;TextBox1.Visible =!TextBox1.Visible ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.65 How to check if the user is using a secure or non secure connection?&lt;br /&gt;&lt;/strong&gt;The Request Object defines a Property called IsSecureConnection, that will indicate whether http:// or https:// has been used.&lt;br /&gt;&lt;strong&gt;2.66 Is it possible to write code in many languages in one ASP.NET project? &lt;/strong&gt;&lt;br /&gt;You cannot write the code-behind files in different languages in the same project, but you can write the aspx pages and ascx controls in different languages.&lt;br /&gt;&lt;strong&gt;2.67 What is the difference between Response.Redirect() and Server.Transfer().&lt;br /&gt;&lt;/strong&gt;Response.Redirect&lt;br /&gt;Transfers the page control to the other page, in other words it sends the request to the other page. Causes the client to navigate to the page you are redirecting to. In http terms it sends a 302 response to the client, and the client goes where it's told. Server.Transfer Only transfers the execution to another page and during this you will see the URL of the old page since only execution is transfered to new page and not control. Occurs entirely on the server, no action is needed by the client Sometimes for performance reasons, the server method is more desirable&lt;br /&gt;&lt;strong&gt;2.68 How to get the hostname or IP address of the server?&lt;br /&gt;&lt;/strong&gt;You can use either of these:&lt;br /&gt;HttpContext.Current.Server.MachineName HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"] The first one should return the name of the machine, the second returns the local ip address. Note that name of the machine could be different than host, since your site could be using host headers&lt;br /&gt;&lt;strong&gt;2.69 What is the meaning of validateRequest=true in .net framework1.1? &lt;/strong&gt;&lt;br /&gt;The value of validateRequest is set to 'true' by default, which means that the framework will automatically deny submission of the '&lt;' and '&gt;' characters.&lt;br /&gt;&lt;strong&gt;2.70 What is the different between &lt;%# %&gt;and &lt;%= %&gt;?&lt;br /&gt;&lt;/strong&gt;The &lt;%# %&gt;is used for databinding where as &lt;%= %&gt;is used to output the result of an expression. The expression inside &lt;%# %&gt;will be executed only when you call the page's or control's DataBind method. The expression inside &lt;%= %&gt;will be executed and displayed as and when it appears in the page.&lt;br /&gt;&lt;strong&gt;2.71 What permissions do ASP.NET applications posses by default? &lt;/strong&gt;&lt;br /&gt;By default ASP.NET Web applications run as ASP.NET user. This user has limited permissions equivalent to the User Group.&lt;br /&gt;&lt;strong&gt;2.72 How can I specify the relative path for a file?&lt;br /&gt;&lt;/strong&gt;Suppose you have following file hierarchy:&lt;br /&gt;default.aspx Admin/login.aspx Misc/testpage.aspx&lt;br /&gt;&lt;br /&gt;And you are on the login.aspx and want your user to navigate to the default.aspx (or testpage.aspx) file. Then you can use&lt;br /&gt;Response.Redirect ("../default.aspx") Response.Redirect ("../Misc/testpage.aspx")&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.73 How can I specify the "upload a file" input textbox in a form to be read only so that the user can click on the browse button and pick a file but they cannot type anything into the textbox next to the browse button.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;2.74 How to change the Page Title dynamically?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;'Declare Protected WithEvents Title1 As System.Web.UI.HtmlControls.HtmlGenericControl&lt;br /&gt;'In Page_Load Title1.InnerText ="Page 1"&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;//Declare protected System.Web.UI.HtmlControls.HtmlGenericControl Title1 ;&lt;br /&gt;//In Page_Load Title1.InnerText ="Page 1" ;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.75 Why do I get the error message "Object must implement IConvertible". How can I resolve it? &lt;/strong&gt;&lt;br /&gt;The common cause for this error is specifying a control as a SqlParameter's Value instead of the control's text value. For example, if you write code as below you'll get the above error:&lt;br /&gt;VB.NET&lt;br /&gt;Dim nameParameter As SqlParameter = command.Parameters.Add("@name", SqlDbType.NVarChar, 50) nameParameter.Value = txtName&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;SqlParameter nameParameter = command.Parameters.Add("@name", SqlDbType.NVarChar, 50); nameParameter.Value = txtName ;&lt;br /&gt;&lt;br /&gt;To resolve it, specify the control's Text property instead of the control itself.&lt;br /&gt;VB.NET&lt;br /&gt;nameParameter.Value = txtName.Text&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;nameParameter.Value =txtName.Text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.76 Why is default.aspx page not opened if i specify &lt;/strong&gt;&lt;a href="http://localhost/"&gt;&lt;strong&gt;http://localhost&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;. I am able to view this page if i hardcode it as &lt;/strong&gt;&lt;a href="http://localhost/default.aspx"&gt;&lt;strong&gt;http://localhost/default.aspx&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;?&lt;br /&gt;&lt;/strong&gt;If some other default page comes higher in the list, adjust the default.aspx to be the number one entry inside the IIS configuration. If you have multiple websites inside IIS, make sure the configuration is applied on the right website (or on all websites by applying the configuration on the server-level using the properties dialog, configure WWW service).&lt;br /&gt;&lt;strong&gt;2.77 Can ASP.NET work on an NT server?&lt;br /&gt;&lt;/strong&gt;No. For more details refer ASP 1.1 version&lt;br /&gt;&lt;strong&gt;2.78 Is it possible to migrate Visual InterDev Design-Time Controls to ASP.NET? &lt;/strong&gt;&lt;br /&gt;Refer INFO: Migrating Visual InterDev Design-Time Controls to ASP.NET&lt;br /&gt;&lt;strong&gt;2.79 How to automatically get the latest version of all the asp.net solution items from Source Safe when opening the solution?&lt;br /&gt;&lt;/strong&gt;In VS.NET you can go to Tools &gt; Options &gt; Source Control &gt; General and check the checkbox for Get everything when a solution opens. This retrieves the latest version of all solution items when you open the solution.&lt;br /&gt;&lt;strong&gt;2.80 How to convert the datetime into a string for use in the SQL ' statement?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;VB.NET&lt;br /&gt;Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then Dim cInfo As CultureInfo For Each cInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures) ddlCulture.Items.Add(cInfo.Name) Next End If End Sub&lt;br /&gt;Private Sub ddlCulture_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCulture.SelectedIndexChanged ' Get a CultureInfo object based on culture selection in dropdownlist Dim cInfo As CultureInfo = New CultureInfo(ddlCulture.SelectedItem.Text) ' Get a CultureInfo object based on Invariant culture Dim cInfoNeutral As CultureInfo = New CultureInfo("") ' Display the datetime based on the formatting of the selected culture TextBox1.Text = Convert.ToString(Now, cInfo.DateTimeFormat) ' Create a DateTime variable to hold the Invariant time Dim dt As DateTime dt = Convert.ToDateTime(TextBox1.Text, cInfo.DateTimeFormat) 'Convert the datetime into a string for use in the SQL statement Label1.Text = "... WHERE ([Date] &lt; '" &amp;amp; _ Convert.ToString(dt, cInfoNeutral.DateTimeFormat) &amp;amp; "')" End Sub C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!Page.IsPostBack ) { foreach(CultureInfo cInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { ddlCulture.Items.Add(cInfo.Name); } } } private void ddlCulture_SelectedIndexChanged(object sender, System.EventArgs e) { // Get a CultureInfo object based on culture selection in dropdownlist CultureInfo cInfo = new CultureInfo(ddlCulture.SelectedItem.Text); // Get a CultureInfo object based on Invariant culture CultureInfo cInfoNeutral = new CultureInfo(""); // Display the datetime based on the formatting of the selected culture TextBox1.Text = Convert.ToString(DateTime.Now , cInfo.DateTimeFormat); // Create a DateTime variable to hold the Invariant time DateTime dt ; dt = Convert.ToDateTime(TextBox1.Text, cInfo.DateTimeFormat); //Convert the datetime into a string for use in the SQL statement Label1.Text = "... WHERE ([Date] &lt; '" + Convert.ToString(dt, cInfoNeutral.DateTimeFormat) + "')"; } &lt;strong&gt;2.81 How to make VS.Net use FlowLayout as the default layout rather than the GridLayout?&lt;br /&gt;&lt;/strong&gt;For VB.NET, go to path C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\WebForm\Templates\1033 Change the following line in the existing WebForm1.aspx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For C#, go to path C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpWebAppWiz\Templates\1033 Change the following line in the existing WebForm1.aspx&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;Note:Before changing any templates it's a good idea to make backup copies of them Or rather than above approach you can change the behavior for new files on a per project basis in Visual Studio by:&lt;br /&gt;Right clicking on the project name (Ex: "WebApplication1)" in Solution Explorer, and select "Properties". From project properties window, under Common Properties&gt;Designer Defaults&gt;Page Layout change "Grid" to "Flow".&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.82 Can I use a DataReader to update/insert/delete a record?&lt;br /&gt;&lt;/strong&gt;No. DataReader provides a means of reading a forward-only stream of rows from a database.&lt;br /&gt;&lt;strong&gt;2.83 What is the difference between Server.Transfer and Server.Execute?&lt;/strong&gt;&lt;br /&gt;Server.Transfer is used to End the current webform and begin executing a new webform. This method works only when navigating to a Web Forms page (.aspx) Server.Execute is used to begin executing a new webform while still displaying the current web form. The contents of both forms are combined. This method works only when navigating to a webform page(.aspx)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.84 How to create a login screen in ASP.NET?&lt;br /&gt;&lt;/strong&gt;Here is a sample login screen:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim myconnection As SqlConnection Dim mycmd As SqlCommand Dim strSql As String Dim myReader As SqlDataReader&lt;br /&gt;Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click myconnection = New SqlConnection("Server=localhost;uid=sa;password=;database=northwind;") strSql = "Select * from usertbl where username=" &amp;amp; "'" &amp;amp; txtUserName.Text &amp;amp; "'" &amp;amp; " and userpassword=" &amp;amp; "'" &amp;amp; txtPassword.Text &amp;amp; "'" mycmd = New SqlCommand(strSql, myconnection) myconnection.Open() myReader = mycmd.ExecuteReader(CommandBehavior.CloseConnection) If myReader.Read() Then Response.Write("Welcome") Else Response.Write("Access Denied") End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;SqlConnection myconnection ; SqlCommand mycmd ; string strSql ; SqlDataReader myReader ; private void btnLogin_Click(object sender, System.EventArgs e) { myconnection = new SqlConnection("Server=localhost;uid=sa;password=;database=northwind;"); strSql = "Select * from usertbl where username=" + "'" + txtUserName.Text + "'" + " and userpassword=" + "'" + txtPassword.Text + "'"; mycmd = new SqlCommand(strSql, myconnection); myconnection.Open(); myReader = mycmd.ExecuteReader(CommandBehavior.CloseConnection); if (myReader.Read() ) { Response.Write("Welcome"); } else { Response.Write("Access Denied"); } }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.85 How to format a Telephone number in the xxx-xxx-xxxx format? &lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim Telno As Double = Double.Parse(ds.Tables(0).Rows(0)("TelNo").ToString()) Response.Write(Telno.ToString("###-###-####"))&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;double Telno= double.Parse(ds.Tables[0].Rows[0]["TelNo"].ToString()); Response.Write(Telno.ToString("###-###-####"));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.86 Can two different programming languages be mixed in a single ASPX file?&lt;br /&gt;&lt;/strong&gt;No. ASP.NET uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language&lt;br /&gt;&lt;strong&gt;2.87 Can I use custom .NET data types in a Web form?&lt;br /&gt;&lt;/strong&gt;Yes. Place the DLL containing the type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced. This is also what happens when you add a custom control from the toolbox to your web form.&lt;br /&gt;&lt;strong&gt;2.88 How can I have a particular Web page in an ASP.NET application which displays its own error page. &lt;/strong&gt;&lt;br /&gt;This can be done by setting the ErroPage attribute of Page Directive or ErrorPage property of Page Class to the desired Custom Error Page&lt;br /&gt;&lt;&lt;a href="mailto:%@Page"&gt;%@Page&lt;/a&gt; Language="C#" ErrorPage="specificerropage.htm"%&gt;&lt;br /&gt;&lt;br /&gt;In web.config&lt;br /&gt;No. The Web browser receives only HTML markup. No source code or web control syntax is passed back to the web browser.&lt;br /&gt;&lt;strong&gt;2.36 Why can't I put where at the top of an ASPX file and write my server-side scripts in C ?&lt;br /&gt;&lt;/strong&gt;The parsers ASP.NET uses to extract code from ASPX files understand C#, Visual Basic.NET, and JScript.NET. You can write server-side scripts in any language supported by a .NET compiler.&lt;br /&gt;&lt;strong&gt;2.37 ASP pages that worked pefectly on Windows 2000 Server and IIS 5.0 do not work on Windows 2003 Server with IIS 6.0. ASP.NET pages work fine. Why?&lt;br /&gt;&lt;/strong&gt;Start -&gt; Settings -&gt; Control Panel -&gt; Administrative Tools -&gt; and double clicking IIS Manager. Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left&lt;br /&gt;&lt;strong&gt;2.38 Why do I get error message "Error creating assembly manifest: Error reading key file 'key.snk' -- The system cannot find the file specified"?&lt;br /&gt;&lt;/strong&gt;Check the location of the key.snk file relative to the assembly file. Provide an explicit path or a relative path.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.39 How to get URL without querystring?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim stringUri As String = "&lt;/span&gt;&lt;/p&gt;&lt;/form&gt;&lt;a href="http://www.syncfusion.com/?id=1&amp;amp;auid=16"&gt;&lt;span style="font-family:verdana;"&gt;http://www.syncfusion.com/?id=1&amp;amp;auid=16&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;" Dim weburi As Uri = New Uri(stringUri) Dim query As String = weburi.Query Dim weburl As String = stringUri.Substring(0, stringUri.Length - query.Length) Response.Write(weburl)&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;string stringUri = "&lt;/span&gt;&lt;a href="http://www.syncfusion.com/?id=1&amp;amp;auid=16"&gt;&lt;span style="font-family:verdana;"&gt;http://www.syncfusion.com/?id=1&amp;amp;auid=16&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;"; Uri weburi = new Uri(stringUri); string query = weburi.Query; string weburl = stringUri.Substring(0, stringUri.Length - query.Length); Response.Write (weburl);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.40 What is the best way to output only time and not Date? &lt;/strong&gt;&lt;br /&gt;Use DateTime as follows VB.NET&lt;br /&gt;Response.Write(DateTime.Now.ToString("hh:mm:ss"))&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write(DateTime.Now.ToString("hh:mm:ss"));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.41 Do I have to compile code if I am changing the content of my aspx.cs file?&lt;br /&gt;&lt;/strong&gt;Yes if you have used Codebehind="my.aspx.cs". Not if you used src="my.aspx.cs" in your page declaration.&lt;br /&gt;&lt;strong&gt;2.42 How to grab the referring URL?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Response.Write ( Request.UrlReferrer.ToString())&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;Response.Write ( Request.UrlReferrer.ToString());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.43 My ASP code gives an error "Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed" when changed to .aspx? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.58 How to validate that a string is a valid date?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim blnValid As Boolean = False Try DateTime.Parse(MyString) blnValid = True Catch blnValid = False End Try&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;bool blnValid=false; try { DateTime.Parse(MyString); blnValid=true; } catch { blnValid=false; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.59 Are namespaces and Class names Case Sensitive? &lt;/strong&gt;&lt;br /&gt;Namespaces and Class names are case Sensitive. Namespaces imported using the @ Import Directive will cause an error if the correct case is not used.&lt;br /&gt;&lt;strong&gt;2.60 How to convert string to a DateTime and compare it with another DateTime?&lt;br /&gt;&lt;/strong&gt;VB.NET&lt;br /&gt;Dim blntimeIsOk As Boolean = DateTime.Parse("15:00") &lt; blntimeisok =" (DateTime.Parse("&gt;2.61 How to get the url of page dynamically?&lt;br /&gt;Use Request.Url property&lt;br /&gt;&lt;strong&gt;2.62 How to convert user input in dMy format to Mdy? &lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim dt As DateTime = DateTime.ParseExact("0299", New String() {"My", "M/y"}, Nothing, System.Globalization.DateTimeStyles.None)&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;DateTime dt = DateTime.ParseExact("0299", new string[] {"My","M/y"}, null,System.Globalization.DateTimeStyles.None);&lt;br /&gt;&lt;br /&gt;For more details refer DateTime.ParseExact&lt;br /&gt;&lt;strong&gt;2.63 When the User is prompted a File Download dialogbox, if the user selects "Save" then the "Save as" dialog box is displayed. Is there any way for me to retrieve the filename and directory path specified by the user on the File Download dialog box?&lt;br /&gt;&lt;/strong&gt;Clients do not report information back about where the user selects to save the content, so there isn't an easy way to do this. Instead, you would need to ask the user before using the content-disposition for a file path, and then you could specify the filename parameter for the content-disposition header. Still, the user is free to change that path when actually downloading.&lt;br /&gt;&lt;strong&gt;2.64 How to hide or show Controls in server side code?&lt;br /&gt;&lt;/strong&gt;In any appropriate event write VB.NET&lt;br /&gt;TextBox1.Visible =not TextBox1.Visible&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;TextBox1.Visible =!TextBox1.Visible ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.65 How to check if the user is using a secure or non secure connection? &lt;/strong&gt;&lt;br /&gt;The Request Object defines a Property called IsSecureConnection, that will indicate whether http:// or https:// has been used.&lt;br /&gt;&lt;strong&gt;2.66 Is it possible to write code in many languages in one ASP.NET project?&lt;br /&gt;&lt;/strong&gt;You cannot write the code-behind files in different languages in the same project, but you can write the aspx pages and ascx controls in different languages.&lt;br /&gt;&lt;strong&gt;2.67 What is the difference between Response.Redirect() and Server.Transfer(). &lt;/strong&gt;&lt;br /&gt;Response.Redirect&lt;br /&gt;Transfers the page control to the other page, in other words it sends the request to the other page. Causes the client to navigate to the page you are redirecting to. In http terms it sends a 302 response to the client, and the client goes where it's told. Server.Transfer Only transfers the execution to another page and during this you will see the URL of the old page since only execution is transfered to new page and not control. Occurs entirely on the server, no action is needed by the client Sometimes for performance reasons, the server method is more desirable&lt;br /&gt;&lt;strong&gt;2.68 How to get the hostname or IP address of the server? &lt;/strong&gt;&lt;br /&gt;You can use either of these:&lt;br /&gt;HttpContext.Current.Server.MachineName HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"] The first one should return the name of the machine, the second returns the local ip address. Note that name of the machine could be different than host, since your site could be using host headers&lt;br /&gt;&lt;strong&gt;2.69 What is the meaning of validateRequest=true in .net framework1.1?&lt;br /&gt;&lt;/strong&gt;The value of validateRequest is set to 'true' by default, which means that the framework will automatically deny submission of the '&lt;' and '&gt;' characters.&lt;br /&gt;&lt;strong&gt;2.70 What is the different between &lt;%# %&gt;and &lt;%= %&gt;? &lt;/strong&gt;&lt;br /&gt;The &lt;%# %&gt;is used for databinding where as &lt;%= %&gt;is used to output the result of an expression. The expression inside &lt;%# %&gt;will be executed only when you call the page's or control's DataBind method. The expression inside &lt;%= %&gt;will be executed and displayed as and when it appears in the page.&lt;br /&gt;&lt;strong&gt;2.71 What permissions do ASP.NET applications posses by default?&lt;br /&gt;&lt;/strong&gt;By default ASP.NET Web applications run as ASP.NET user. This user has limited permissions equivalent to the User Group.&lt;br /&gt;&lt;strong&gt;2.72 How can I specify the relative path for a file? &lt;/strong&gt;&lt;br /&gt;Suppose you have following file hierarchy:&lt;br /&gt;default.aspx Admin/login.aspx Misc/testpage.aspx&lt;br /&gt;&lt;br /&gt;And you are on the login.aspx and want your user to navigate to the default.aspx (or testpage.aspx) file. Then you can use&lt;br /&gt;Response.Redirect ("../default.aspx") Response.Redirect ("../Misc/testpage.aspx")&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.73 How can I specify the "upload a file" input textbox in a form to be read only so that the user can click on the browse button and pick a file but they cannot type anything into the textbox next to the browse button.&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;2.74 How to change the Page Title dynamically?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;'Declare Protected WithEvents Title1 As System.Web.UI.HtmlControls.HtmlGenericControl&lt;br /&gt;'In Page_Load Title1.InnerText ="Page 1"&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;//Declare protected System.Web.UI.HtmlControls.HtmlGenericControl Title1 ;&lt;br /&gt;//In Page_Load Title1.InnerText ="Page 1" ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.75 Why do I get the error message "Object must implement IConvertible". How can I resolve it? &lt;/strong&gt;&lt;br /&gt;The common cause for this error is specifying a control as a SqlParameter's Value instead of the control's text value. For example, if you write code as below you'll get the above error:&lt;br /&gt;VB.NET&lt;br /&gt;Dim nameParameter As SqlParameter = command.Parameters.Add("@name", SqlDbType.NVarChar, 50) nameParameter.Value = txtName&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;SqlParameter nameParameter = command.Parameters.Add("@name", SqlDbType.NVarChar, 50); nameParameter.Value = txtName ;&lt;br /&gt;&lt;br /&gt;To resolve it, specify the control's Text property instead of the control itself.&lt;br /&gt;VB.NET&lt;br /&gt;nameParameter.Value = txtName.Text&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;nameParameter.Value =txtName.Text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.76 Why is default.aspx page not opened if i specify &lt;/strong&gt;&lt;/span&gt;&lt;a href="http://localhost/"&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;http://localhost&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;. I am able to view this page if i hardcode it as &lt;/strong&gt;&lt;/span&gt;&lt;a href="http://localhost/default.aspx"&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;http://localhost/default.aspx&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt; &lt;p&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;?&lt;br /&gt;&lt;/strong&gt;If some other default page comes higher in the list, adjust the default.aspx to be the number one entry inside the IIS configuration. If you have multiple websites inside IIS, make sure the configuration is applied on the right website (or on all websites by applying the configuration on the server-level using the properties dialog, configure WWW service).&lt;br /&gt;&lt;strong&gt;2.77 Can ASP.NET work on an NT server?&lt;br /&gt;&lt;/strong&gt;No. For more details refer ASP 1.1 version&lt;br /&gt;&lt;strong&gt;2.78 Is it possible to migrate Visual InterDev Design-Time Controls to ASP.NET?&lt;br /&gt;&lt;/strong&gt;Refer INFO: Migrating Visual InterDev Design-Time Controls to ASP.NET&lt;br /&gt;&lt;strong&gt;2.79 How to automatically get the latest version of all the asp.net solution items from Source Safe when opening the solution?&lt;br /&gt;&lt;/strong&gt;In VS.NET you can go to Tools &gt; Options &gt; Source Control &gt; General and check the checkbox for Get everything when a solution opens. This retrieves the latest version of all solution items when you open the solution.&lt;br /&gt;&lt;strong&gt;2.80 How to convert the datetime into a string for use in the SQL ' statement?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then Dim cInfo As CultureInfo For Each cInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures) ddlCulture.Items.Add(cInfo.Name) Next End If End Sub&lt;br /&gt;Private Sub ddlCulture_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCulture.SelectedIndexChanged ' Get a CultureInfo object based on culture selection in dropdownlist Dim cInfo As CultureInfo = New CultureInfo(ddlCulture.SelectedItem.Text) ' Get a CultureInfo object based on Invariant culture Dim cInfoNeutral As CultureInfo = New CultureInfo("") ' Display the datetime based on the formatting of the selected culture TextBox1.Text = Convert.ToString(Now, cInfo.DateTimeFormat) ' Create a DateTime variable to hold the Invariant time Dim dt As DateTime dt = Convert.ToDateTime(TextBox1.Text, cInfo.DateTimeFormat) 'Convert the datetime into a string for use in the SQL statement Label1.Text = "... WHERE ([Date] &lt; '" &amp;amp; _ Convert.ToString(dt, cInfoNeutral.DateTimeFormat) &amp;amp; "')" End Sub C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!Page.IsPostBack ) { foreach(CultureInfo cInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { ddlCulture.Items.Add(cInfo.Name); } } } private void ddlCulture_SelectedIndexChanged(object sender, System.EventArgs e) { // Get a CultureInfo object based on culture selection in dropdownlist CultureInfo cInfo = new CultureInfo(ddlCulture.SelectedItem.Text); // Get a CultureInfo object based on Invariant culture CultureInfo cInfoNeutral = new CultureInfo(""); // Display the datetime based on the formatting of the selected culture TextBox1.Text = Convert.ToString(DateTime.Now , cInfo.DateTimeFormat); // Create a DateTime variable to hold the Invariant time DateTime dt ; dt = Convert.ToDateTime(TextBox1.Text, cInfo.DateTimeFormat); //Convert the datetime into a string for use in the SQL statement Label1.Text = "... WHERE ([Date] &lt; '" + Convert.ToString(dt, cInfoNeutral.DateTimeFormat) + "')"; } &lt;strong&gt;2.81 How to make VS.Net use FlowLayout as the default layout rather than the GridLayout?&lt;br /&gt;&lt;/strong&gt;For VB.NET, go to path C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\WebForm\Templates\1033 Change the following line in the existing WebForm1.aspx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For C#, go to path C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpWebAppWiz\Templates\1033 Change the following line in the existing WebForm1.aspx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note:Before changing any templates it's a good idea to make backup copies of them Or rather than above approach you can change the behavior for new files on a per project basis in Visual Studio by:&lt;br /&gt;Right clicking on the project name (Ex: "WebApplication1)" in Solution Explorer, and select "Properties". From project properties window, under Common Properties&gt;Designer Defaults&gt;Page Layout change "Grid" to "Flow".&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.82 Can I use a DataReader to update/insert/delete a record?&lt;br /&gt;&lt;/strong&gt;No. DataReader provides a means of reading a forward-only stream of rows from a database.&lt;br /&gt;&lt;strong&gt;2.83 What is the difference between Server.Transfer and Server.Execute?&lt;/strong&gt;&lt;br /&gt;Server.Transfer is used to End the current webform and begin executing a new webform. This method works only when navigating to a Web Forms page (.aspx) Server.Execute is used to begin executing a new webform while still displaying the current web form. The contents of both forms are combined. This method works only when navigating to a webform page(.aspx)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.84 How to create a login screen in ASP.NET?&lt;br /&gt;&lt;/strong&gt;Here is a sample login screen:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim myconnection As SqlConnection Dim mycmd As SqlCommand Dim strSql As String Dim myReader As SqlDataReader&lt;br /&gt;Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click myconnection = New SqlConnection("Server=localhost;uid=sa;password=;database=northwind;") strSql = "Select * from usertbl where username=" &amp;amp; "'" &amp;amp; txtUserName.Text &amp;amp; "'" &amp;amp; " and userpassword=" &amp;amp; "'" &amp;amp; txtPassword.Text &amp;amp; "'" mycmd = New SqlCommand(strSql, myconnection) myconnection.Open() myReader = mycmd.ExecuteReader(CommandBehavior.CloseConnection) If myReader.Read() Then Response.Write("Welcome") Else Response.Write("Access Denied") End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;SqlConnection myconnection ; SqlCommand mycmd ; string strSql ; SqlDataReader myReader ; private void btnLogin_Click(object sender, System.EventArgs e) { myconnection = new SqlConnection("Server=localhost;uid=sa;password=;database=northwind;"); strSql = "Select * from usertbl where username=" + "'" + txtUserName.Text + "'" + " and userpassword=" + "'" + txtPassword.Text + "'"; mycmd = new SqlCommand(strSql, myconnection); myconnection.Open(); myReader = mycmd.ExecuteReader(CommandBehavior.CloseConnection); if (myReader.Read() ) { Response.Write("Welcome"); } else { Response.Write("Access Denied"); } }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.85 How to format a Telephone number in the xxx-xxx-xxxx format? &lt;/strong&gt;&lt;br /&gt;VB.NET&lt;br /&gt;Dim Telno As Double = Double.Parse(ds.Tables(0).Rows(0)("TelNo").ToString()) Response.Write(Telno.ToString("###-###-####"))&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;double Telno= double.Parse(ds.Tables[0].Rows[0]["TelNo"].ToString()); Response.Write(Telno.ToString("###-###-####"));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2.86 Can two different programming languages be mixed in a single ASPX file?&lt;br /&gt;&lt;/strong&gt;No. ASP.NET uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language&lt;br /&gt;&lt;strong&gt;2.87 Can I use custom .NET data types in a Web form?&lt;br /&gt;&lt;/strong&gt;Yes. Place the DLL containing the type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced. This is also what happens when you add a custom control from the toolbox to your web form.&lt;br /&gt;&lt;strong&gt;2.88 How can I have a particular Web page in an ASP.NET application which displays its own error page. &lt;/strong&gt;&lt;br /&gt;This can be done by setting the ErroPage attribute of Page Directive or ErrorPage property of Page Class to the desired Custom Error Page&lt;br /&gt;&lt;&lt;/span&gt;&lt;a href="mailto:%@Page"&gt;&lt;span style="font-family:verdana;"&gt;%@Page&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; Language="C#" ErrorPage="specificerropage.htm"%&gt;&lt;br /&gt;&lt;br /&gt;In web.config&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5721395117775713000?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5721395117775713000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5721395117775713000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5721395117775713000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5721395117775713000'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/faqs-on-aspnet-part1.html' title='Faqs on asp.net - part1'/><author><name>.NET team</name><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-2557049885090666521.post-2803688785469357006</id><published>2008-02-15T16:54:00.000+05:30</published><updated>2008-02-15T16:59:24.671+05:30</updated><title type='text'>Faqs on Sqlserver2005-part2</title><content type='html'>&lt;font face="verdana"&gt;&lt;strong&gt;What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?&lt;/strong&gt;&lt;br /&gt;Cursors allow row-by-row prcessing of the resultsets.Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.Most of the times, set based operations can be used instead of cursors. Here is an example:If you have to give a flat hike to your employees using the following criteria:Salary between 30000 and 40000 -- 5000 hikeSalary between 40000 and 55000 -- 7000 hikeSalary between 55000 and 65000 -- 9000 hikeIn this situation many developers tend to use a cursor, determine each employee's salary and update his salary according to the above formula. But the same can be achieved by multiple update statements or can be combined in a single UPDATE statement as shown below:UPDATE tbl_emp SET salary = CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000ENDAnother situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don't have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row. For examples of using WHILE loop for row by row processingWrite down the general syntax for a SELECT statements covering all the options.&lt;br /&gt;Here's the basic syntax: (Also checkout SELECT in books online for advanced syntax).SELECT select_list[INTO new_table_]FROM table_source[WHERE search_condition][GROUP BY group_by_expression][HAVING search_condition][ORDER BY order_expression [ASC  DESC] ]&lt;br /&gt;&lt;strong&gt;What is a join and explain different types of joins.&lt;/strong&gt;&lt;br /&gt;Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table. Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.For more information see pages from books online titled: "Join Fundamentals" and "Using Joins".&lt;br /&gt;&lt;strong&gt;Can you have a nested transaction?&lt;/strong&gt;&lt;br /&gt;Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and @@TRANCOUNT&lt;br /&gt;What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?&lt;br /&gt;An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way we call normal stored procedures using the EXEC statement. See books online to learn how to create extended stored procedures and how to add them to SQL Server. Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. Also see books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty, sp_OADestroy&lt;/font&gt;&lt;br /&gt;&lt;font face="verdana"&gt;&lt;strong&gt;What is the system function to get the current user's user id?&lt;br /&gt;&lt;/strong&gt;USER_ID(). Also check out other system functions like USER_NAME(), SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME().&lt;br /&gt;&lt;strong&gt;What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?&lt;/strong&gt;&lt;br /&gt;Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action. But in 7.0 there's no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorderTriggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers. Also check out books online for 'inserted table', 'deleted table' and COLUMNS_UPDATED()&lt;br /&gt;&lt;strong&gt;There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better?&lt;/strong&gt;&lt;br /&gt;Instantiating COM objects is a time consuming process and since you are doing it from within a trigger, it slows down the data insertion process. Same is the case with sending emails from triggers. This scenario can be better implemented by logging all the necessary data into a separate table, and have a job which periodically checks this table and does the needful.&lt;br /&gt;&lt;strong&gt;What is a self join? Explain it with an example.&lt;/strong&gt;&lt;br /&gt;Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.CREATE TABLE emp (empid int,mgrid int,empname char(10))INSERT emp SELECT 1,2,'Vyas'INSERT emp SELECT 2,3,'Mohan'INSERT emp SELECT 3,NULL,'Shobha'INSERT emp SELECT 4,2,'Shridhar'INSERT emp SELECT 5,2,'Sourabh'SELECT t1.empname [Employee], t2.empname [Manager]FROM emp t1, emp t2WHERE t1.mgrid = t2.empid&lt;br /&gt;Here's an advanced query using a LEFT OUTER JOIN that even returns the employees without managers (super bosses)SELECT t1.empname [Employee], COALESCE(t2.empname, 'No manager') [Manager]FROM emp t1 LEFT OUTER JOINemp t2ON t1.mgrid = t2.empid&lt;br /&gt;&lt;/font&gt;&lt;strong&gt;&lt;font face="verdana"&gt;Given an employee table, how would you find out the second highest salary?&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-2803688785469357006?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/2803688785469357006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=2803688785469357006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2803688785469357006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2803688785469357006'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/faqs-on-sqlserver2005-part2.html' title='Faqs on Sqlserver2005-part2'/><author><name>.NET team</name><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-2557049885090666521.post-2302581576438960303</id><published>2008-02-15T16:48:00.000+05:30</published><updated>2008-02-15T16:54:08.343+05:30</updated><title type='text'>Faqs on Sqlserver2005-1</title><content type='html'>&lt;span style="color:#ff0000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is normalization? Explain different levels of normalization?&lt;/strong&gt;&lt;br /&gt;Check out the article Q100139 from Microsoft knowledge base and of course, there's much more information available in the net. It'll be a good idea to get a hold of any RDBMS fundamentals text book, especially the one by C. J. Date. Most of the times, it will be okay if you can explain till third normal form.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is denormalization and when would you go for it?&lt;br /&gt;&lt;/strong&gt;As the name indicates, denormalization is the reverse process of normalization. It's the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.&lt;br /&gt;&lt;strong&gt;How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?&lt;/strong&gt;&lt;br /&gt;One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships.One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships.Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.It will be a good idea to read up a database designing fundamentals text book.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What's the difference between a primary key and a unique key?&lt;br /&gt;&lt;/strong&gt;Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.&lt;br /&gt;&lt;strong&gt;What are user defined datatypes and when you should go for them?&lt;/strong&gt;&lt;br /&gt;User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called Flight_Num which appears in many tables. In all these tables it should be varchar(8). In this case you could create a user defined datatype called Flight_num_type of varchar(8) and use it across all your tables. See sp_addtype, sp_droptype in books online.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is bit datatype and what's the information that can be stored inside a bit column?&lt;br /&gt;&lt;/strong&gt;Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit datatype can represent a third state, which is NULL.&lt;br /&gt;Define candidate key, alternate key, composite key.&lt;br /&gt;A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys. A key formed by combining at least two or more columns is called composite key.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are defaults? Is there a column to which a default can't be bound?&lt;br /&gt;&lt;/strong&gt;A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them. See CREATE DEFUALT in books online.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a name="Architecture"&gt;&lt;strong&gt;&lt;span style="font-family:verdana;"&gt;SQL Server architecture&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is a transaction and what are ACID properties?&lt;/strong&gt;&lt;br /&gt;A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction. For more information and explanation of these properties, see SQL Server books online or any RDBMS fundamentals text book.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Explain different isolation levels?&lt;br /&gt;&lt;/strong&gt;An isolation level determines the degree of isolation of data between concurrent transactions. The default SQL Server isolation level is Read Committed. Here are the other isolation levels (in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read, Serializable. See SQL Server books online for an explanation of the isolation levels. Be sure to read about SET TRANSACTION ISOLATION LEVEL, which lets you customize the isolation level at the connection level.&lt;br /&gt;&lt;strong&gt;CREATE INDEX myIndex ON myTable(myColumn)What type of Index will get created after executing the above statement?&lt;/strong&gt;&lt;br /&gt;Non-clustered index. Important thing to note: By default a clustered index gets created on the primary key, unless specified otherwise.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What's the maximum size of a row?&lt;br /&gt;&lt;/strong&gt;8060 bytes. Don't be surprised with questions like 'what is the maximum number of columns per table'. Check out SQL Server books online for the page titled: "Maximum Capacity Specifications".&lt;br /&gt;&lt;strong&gt;Explain Active/Active and Active/Passive cluster configurations?&lt;/strong&gt;&lt;br /&gt;Hopefully you have experience setting up cluster servers. But if you don't, at least be familiar with the way clustering works and the two clusterning configurations Active/Active and Active/Passive. SQL Server books online has enough information on this topic and there is a good white paper available on Microsoft site.&lt;br /&gt;&lt;strong&gt;Explain the architecture of SQL Server?&lt;/strong&gt;&lt;br /&gt;This is a very important question and you better be able to answer it if consider yourself a DBA. SQL Server books online is the best place to read about SQL Server architecture. Read up the chapter dedicated to SQL Server Architecture.&lt;br /&gt;&lt;strong&gt;What is lock escalation?&lt;/strong&gt;&lt;br /&gt;Lock escalation is the process of converting a lot of low level locks (like row locks, page locks) into higher level locks (like table locks). Every lock is a memory structure too many locks would mean, more memory being occupied by locks. To prevent this from happening, SQL Server escalates the many fine-grain locks to fewer coarse-grain locks. Lock escalation threshold was definable in SQL Server 6.5, but from SQL Server 7.0 onwards it's dynamically managed by SQL Server.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What's the difference between DELETE TABLE and TRUNCATE TABLE commands?&lt;br /&gt;&lt;/strong&gt;DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it won't log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.&lt;br /&gt;&lt;strong&gt;Explain the storage models of OLAP?&lt;/strong&gt;&lt;br /&gt;Check out MOLAP, ROLAP and HOLAP in SQL Server books online for more infomation.&lt;br /&gt;&lt;strong&gt;What are the new features introduced in SQL Server 2000 (or the latest release of SQL Server at the time of your interview)? What changed between the previous version of SQL Server and the current version?&lt;/strong&gt;&lt;br /&gt;This question is generally asked to see how current is your knowledge. Generally there is a section in the beginning of the books online titled "What's New", which has all such information. Of course, reading just that is not enough, you should have tried those things to better answer the questions. Also check out the section titled "Backward Compatibility" in books online which talks about the changes that have taken place in the new version.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are constraints? Explain different types of constraints.&lt;br /&gt;&lt;/strong&gt;Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults. Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEYFor an explanation of these constraints see books online for the pages titled: "Constraints" and "CREATE TABLE", "ALTER TABLE"&lt;br /&gt;&lt;strong&gt;Whar is an index? What are the types of indexes? How many clustered indexes can be created on a table? I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?&lt;/strong&gt;&lt;br /&gt;Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it's row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-2302581576438960303?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/2302581576438960303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=2302581576438960303' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2302581576438960303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/2302581576438960303'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/faqs-on-sqlserver2005-1.html' title='Faqs on Sqlserver2005-1'/><author><name>.NET team</name><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-2557049885090666521.post-7019389713111001876</id><published>2008-02-15T16:42:00.001+05:30</published><updated>2008-02-15T16:48:00.010+05:30</updated><title type='text'>Faqs on Sqlserver Database Administration</title><content type='html'>&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is RAID and what are different types of RAID configurations?&lt;br /&gt;&lt;/strong&gt;RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance. MSDN has some information about RAID levels and for detailed information, check out the &lt;/span&gt;&lt;a href="http://www.raid-advisory.com/" target="_new"&gt;&lt;span style="font-family:verdana;"&gt;RAID advisory board's homepage&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are the steps you will take to improve performance of a poor performing query?&lt;/strong&gt;&lt;br /&gt;This is a very open ended question and there could be a lot of reasons behind the poor performance of a query. But some general issues that you could talk about would be: No indexes, table scans, missing or out of date statistics, blocking, excess recompilations of stored procedures, procedures and triggers without SET NOCOUNT ON, poorly written query with unnecessarily complicated joins, too much normalization, excess usage of cursors and temporary tables.Some of the tools/ways that help you troubleshooting performance problems are: SET SHOWPLAN_ALL ON, SET SHOWPLAN_TEXT ON, SET STATISTICS IO ON, SQL Server Profiler, Windows NT /2000 Performance monitor, Graphical execution plan in Query Analyzer.Download the white paper on performance tuning SQL Server from Microsoft web site. Don't forget to check out &lt;/span&gt;&lt;a href="http://www.sql-server-performance.com/" target="_new"&gt;&lt;span style="font-family:verdana;"&gt;sql-server-performance.com&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are the steps you will take, if you are tasked with securing an SQL Server?&lt;br /&gt;&lt;/strong&gt;Again this is another open ended question. Here are some things you could talk about: Preferring NT authentication, using server, databse and application roles to control access to the data, securing the physical database files using NTFS permissions, using an unguessable SA password, restricting physical access to the SQL Server, renaming the Administrator account on the SQL Server computer, disabling the Guest account, enabling auditing, using multiprotocol encryption, setting up SSL, setting up firewalls, isolating SQL Server from the web server etc.Read the white paper on SQL Server security from Microsoft website. Also check out &lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/sql_server_security_best_practices.htm" target="_new"&gt;&lt;span style="font-family:verdana;"&gt;My SQL Server security best practices&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What is a deadlock and what is a live lock? How will you go about resolving deadlocks?&lt;/strong&gt;&lt;br /&gt;Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other's piece. Each process  would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user's process.A livelock is one, where a  request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.Check out SET DEADLOCK_PRIORITY and "Minimizing Deadlocks"  in SQL Server books online. Also check out the article Q169960 from Microsoft knowledge base.&lt;br /&gt;&lt;strong&gt;What is blocking and how would you troubleshoot it?&lt;/strong&gt;&lt;br /&gt;Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock type. This forces the second connection to wait, blocked on the first. Read up the following topics in SQL Server books online: Understanding and avoiding blocking, Coding efficient transactions.&lt;br /&gt;Explain CREATE DATABASE syntax&lt;br /&gt;Many of us are used to craeting databases from the Enterprise Manager or by just issuing the command: CREATE DATABAE MyDB. But what if you have to create a database with two filegroups, one on drive C and the other on drive D with log on drive E with an initial size of 600 MB and with a growth factor of 15%? That's why being a DBA you should be familiar with the CREATE DATABASE syntax. Check out SQL Server books online for more information.&lt;br /&gt;&lt;strong&gt;How to restart SQL Server in single user mode? How to start SQL Server in minimal configuration mode?&lt;br /&gt;&lt;/strong&gt;SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some very important parameters with which a DBA should be familiar with. -m is used for starting SQL Server in single user mode and -f is used to start the SQL Server in minimal confuguration mode. Check out SQL Server books online for more parameters and their explanations.&lt;br /&gt;&lt;strong&gt;As a part of your job, what are the DBCC commands that you commonly use for database maintenance?&lt;/strong&gt;&lt;br /&gt;DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKCATALOG, DBCC CHECKALLOC, DBCC SHOWCONTIG, DBCC SHRINKDATABASE, DBCC SHRINKFILE etc. But there are a whole load of DBCC commands which are very useful for DBAs. Check out SQL Server books online for more information.&lt;br /&gt;&lt;strong&gt;What are statistics, under what circumstances they go out of date, how do you update them?&lt;br /&gt;&lt;/strong&gt;Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query. Some situations under which you should update statistics:1) If there is significant change in the key values in the index2) If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated3) Database is upgraded from a previous versionLook up SQL Server books online for the following commands: UPDATE STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE STATISTICS, DROP STATISTICS, sp_autostats, sp_createstats, sp_updatestats&lt;br /&gt;&lt;strong&gt;What are the different ways of moving data/databases between servers and databases in SQL Server?&lt;/strong&gt;&lt;br /&gt;There are lots of options available, you have to choose your option depending upon your requirements. Some of the options you have are: BACKUP/RESTORE, dettaching and attaching databases, replication, DTS, BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating INSERT scripts to generate data.&lt;br /&gt;Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about &lt;strong&gt;choosing a backup plan?&lt;br /&gt;&lt;/strong&gt;Types of backups you can create in SQL Sever 7.0+ are Full database backup, differential database backup, transaction log backup, filegroup backup. Check out the BACKUP and RESTORE commands in SQL Server books online. Be prepared to write the commands in your interview. Books online also has information on detailed backup/restore architecture and when one should go for a particular kind of backup.&lt;br /&gt;&lt;strong&gt;What is database replicaion? What are the different types of replication you can set up in SQL Server?&lt;br /&gt;&lt;/strong&gt;Replication is the process of copying/moving data between databases on the same or different servers. SQL Server supports the following types of replication scenarios:&lt;br /&gt;Snapshot replication&lt;br /&gt;Transactional replication (with immediate updating subscribers, with queued updating subscribers)&lt;br /&gt;Merge replication&lt;br /&gt;See SQL Server books online for indepth coverage on replication. Be prepared to explain how different replication agents function, what are the main system tables used in replication etc.&lt;br /&gt;&lt;strong&gt;How to determine the service pack currently installed on SQL Server?&lt;/strong&gt;&lt;br /&gt;The global variable @@Version stores the build number of the sqlservr.exe, which is used to determine the service pack installed. To know more about this process visit &lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/sqlsps.htm"&gt;&lt;span style="font-family:verdana;"&gt;SQL Server service packs and versions.&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="DBProg"&gt;&lt;span style="font-family:verdana;"&gt;Database programming&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?&lt;br /&gt;&lt;/strong&gt;Cursors allow row-by-row prcessing of the resultsets.Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.Most of the times, set based operations can be used instead of cursors. Here is an example:If you have to give a flat hike to your employees using the following criteria:Salary between 30000 and 40000 -- 5000 hikeSalary between 40000 and 55000 -- 7000 hikeSalary between 55000 and 65000 -- 9000 hikeIn this situation many developers tend to use a cursor, determine each employee's salary and update his salary according to the above formula. But the same can be achieved by multiple update statements or can be combined in a single UPDATE statement as shown below:UPDATE tbl_emp SET salary = CASE WHEN salary BETWEEN 30000 AND 40000 THEN salary + 5000WHEN salary BETWEEN 40000 AND 55000 THEN salary + 7000WHEN salary BETWEEN 55000 AND 65000 THEN salary + 10000ENDAnother situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don't have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row. For examples of using WHILE loop for row by row processing, check out the '&lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/code.htm"&gt;&lt;span style="font-family:verdana;"&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;' section of my site or &lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/search.htm"&gt;&lt;span style="font-family:verdana;"&gt;search&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; for WHILE.&lt;br /&gt;Write down the general syntax for a SELECT statements covering all the options.&lt;br /&gt;Here's the basic syntax: (Also checkout SELECT in books online for advanced syntax).SELECT select_list[INTO new_table_]FROM table_source[WHERE search_condition][GROUP BY group_by_expression][HAVING search_condition][ORDER BY order_expression [ASC  DESC] ]&lt;br /&gt;&lt;strong&gt;What is a join and explain different types of joins.&lt;/strong&gt;&lt;br /&gt;Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table. Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.For more information see pages from books online titled: "Join Fundamentals" and "Using Joins".&lt;br /&gt;&lt;strong&gt;Can you have a nested transaction?&lt;br /&gt;&lt;/strong&gt;Yes, very much. Check out BEGIN TRAN, COMMIT, ROLLBACK, SAVE TRAN and @@TRANCOUNT&lt;br /&gt;What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?&lt;br /&gt;An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way we call normal stored procedures using the EXEC statement. See books online to learn how to create extended stored procedures and how to add them to SQL Server. Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. Also see books online for sp_OAMethod, sp_OAGetProperty, sp_OASetProperty, sp_OADestroy. For an example of creating a COM object in VB and calling it from T-SQL, see '&lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/code.htm"&gt;&lt;span style="font-family:verdana;"&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;' section of this site.&lt;br /&gt;&lt;strong&gt;What is the system function to get the current user's user id?&lt;/strong&gt;&lt;br /&gt;USER_ID(). Also check out other system functions like USER_NAME(), SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME().&lt;br /&gt;&lt;strong&gt;What are triggers? How many triggers you can have on a table? How to invoke a trigger on demand?&lt;br /&gt;&lt;/strong&gt;Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table. In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action. But in 7.0 there's no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorderTriggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers. Also check out books online for 'inserted table', 'deleted table' and COLUMNS_UPDATED()&lt;br /&gt;There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this &lt;strong&gt;implementation? Can this be implemented better?&lt;/strong&gt;&lt;br /&gt;Instantiating COM objects is a time consuming process and since you are doing it from within a trigger, it slows down the data insertion process. Same is the case with sending emails from triggers. This scenario can be better implemented by logging all the necessary data into a separate table, and have a job which periodically checks this table and does the needful.&lt;br /&gt;&lt;strong&gt;What is a self join? Explain it with an example.&lt;br /&gt;&lt;/strong&gt;Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.CREATE TABLE emp (empid int,mgrid int,empname char(10))INSERT emp SELECT 1,2,'Vyas'INSERT emp SELECT 2,3,'Mohan'INSERT emp SELECT 3,NULL,'Shobha'INSERT emp SELECT 4,2,'Shridhar'INSERT emp SELECT 5,2,'Sourabh'SELECT t1.empname [Employee], t2.empname [Manager]FROM emp t1, emp t2WHERE t1.mgrid = t2.empid&lt;br /&gt;Here's an advanced query using a LEFT OUTER JOIN that even returns the employees without managers (super bosses)SELECT t1.empname [Employee], COALESCE(t2.empname, 'No manager') [Manager]FROM emp t1 LEFT OUTER JOINemp t2ON t1.mgrid = t2.empid&lt;br /&gt;&lt;strong&gt;Given an employee table, how would you find out the second highest salary?&lt;/strong&gt;&lt;br /&gt;For a solution see the '&lt;/span&gt;&lt;a href="http://vyaskn.tripod.com/code.htm"&gt;&lt;span style="font-family:verdana;"&gt;My code library&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;' section of this site.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-7019389713111001876?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/7019389713111001876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=7019389713111001876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7019389713111001876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/7019389713111001876'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/faqs-on-sqlserver-database.html' title='Faqs on Sqlserver Database Administration'/><author><name>.NET team</name><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-2557049885090666521.post-5069348062957112721</id><published>2008-02-15T15:39:00.000+05:30</published><updated>2008-02-15T16:40:03.843+05:30</updated><title type='text'>faqs on asp.net-1</title><content type='html'>&lt;span style="font-family:verdana;"&gt;1. &lt;strong&gt;Development and Deployment Issues&lt;/strong&gt;&lt;br /&gt;1.1&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q4q"&gt;&lt;span style="font-family:verdana;"&gt;Why are Server control tags shown in the browser instead of the controls it represents?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.2&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q1q"&gt;&lt;span style="font-family:verdana;"&gt;How To Repair ASP.Net IIS Mapping After You Remove and Reinstall IIS?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.3&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q341q"&gt;&lt;span style="font-family:verdana;"&gt;Why do I get "HTTP 500" error (or "(DLL) initialization routine failed") in my browser?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.4&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q500q"&gt;&lt;span style="font-family:verdana;"&gt;I have recently move my Web application from Windows 2k to Windows Server 2003. All works fine in Windows 2K but i am not able to view pages using Windows Server 2003?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.5&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q454q"&gt;&lt;span style="font-family:verdana;"&gt;What are the Best practices for side-by-side execution of Framework 1.0 and 1.1?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.6&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q455q"&gt;&lt;span style="font-family:verdana;"&gt;Can I have VS.NET and the Visual Studio 6.0 installed on the same machine?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.7&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q462q"&gt;&lt;span style="font-family:verdana;"&gt;How should I check whether IIS is installed or not?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.8&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q147q"&gt;&lt;span style="font-family:verdana;"&gt;In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.9&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q40q"&gt;&lt;span style="font-family:verdana;"&gt;Why do I get the error message "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request."?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.10&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q146q"&gt;&lt;span style="font-family:verdana;"&gt;In Visual Studio .NET, how do I create a new ASP.NET application which does not have a physical path under wwwroot?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.11&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q508q"&gt;&lt;span style="font-family:verdana;"&gt;Why do I get the "Unable to find script library 'WebUIValidation.js'" error ?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.12&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q576q"&gt;&lt;span style="font-family:verdana;"&gt;After installing .NET Framework SP1 the client side validations, or rather validator controls are not working?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.13&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q580q"&gt;&lt;span style="font-family:verdana;"&gt;How to Configure the ASP.NET Version to use for Each Application(developed using 1.0 or 1.1)?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.14&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q581q"&gt;&lt;span style="font-family:verdana;"&gt;How to Configure Different Versions of an ASP.NET Application Running on the Same Web Server?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.15&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q597q"&gt;&lt;span style="font-family:verdana;"&gt;Why do I get error message "Internet Explorer cannot download MyPage.aspx from MyWebSite.com ..."?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;1.16&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2557049885090666521#q336q"&gt;&lt;span style="font-family:verdana;"&gt;Why do I get error message "Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. ..."?&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a name="#q4q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.1 Why are Server control tags shown in the browser instead of the controls it represents?&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;This is because the server control tags were not converted into their respecting HTML element tags by ASP.Net. This happens when ASP.Net is not properly registered with IIS.&lt;br /&gt;.Net framework provides an Administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single machine. You can find the file in C:\WINNT\Microsoft.NET\Framework\v**\aspnet_regiis.exe&lt;br /&gt;use the command: aspnet_regiis.exe -u ---&gt; to uninstall current asp.net version.&lt;br /&gt;use the command: aspnet_regiis.exe -i ---&gt; to install current asp.net version.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q1q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.2 How To Repair ASP.Net IIS Mapping After You Remove and Reinstall IIS? &lt;/strong&gt;&lt;br /&gt;To reassociate aspx file extensions with ASP.Net runtime, you'll have to run the utility aspnet_regiis.exe -i For more information refer to &lt;/span&gt;&lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;306005"&gt;&lt;span style="font-family:verdana;"&gt;Microsoft Knowledge Base Article - 306005 &lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="#q341q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.3 Why do I get "HTTP 500" error (or "(DLL) initialization routine failed") in my browser?&lt;br /&gt;&lt;/strong&gt;This is because if you have the /3GB boot switch enabled, the ASP.NET worker process (Aspnet_wp.exe) does not start. For more information see &lt;/span&gt;&lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;320353"&gt;&lt;span style="font-family:verdana;"&gt;Microsoft Knowledge Base Article - 320353 &lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;To create and set the "ASPNETENABLE3GB" environment variable as mentioned in the above article, right click MyComputer -&gt;Properties-&gt;Advanced &gt; Environment Variables &gt; System variables &gt; New. Add the variable name in the top text box and the value in the lower textbox.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q500q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.4 I have recently move my Web application from Windows 2k to Windows Server 2003. All works fine in Windows 2K but i am not able to view pages using Windows Server 2003?&lt;br /&gt;&lt;/strong&gt;You have to enable the ASP.NET in the Web Server Extensions listFrom Start -&gt; Settings -&gt; Control Panel -&gt; Administrative Tools -&gt; double click IIS Manager. Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q454q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.5 What are the Best practices for side-by-side execution of Framework 1.0 and 1.1?&lt;br /&gt;&lt;/strong&gt;In ASP.NET, applications are said to be running side by side when they are installed on the same computer, but use different versions of the .NET Framework. The following article at www.asp.net details the practices that are recommended &lt;/span&gt;&lt;a href="http://www.asp.net/faq/SideBySide.aspx"&gt;&lt;span style="font-family:verdana;"&gt;ASP.NET Side-by-Side Execution of .NET Framework 1.0 and 1.1 &lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="#q455q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.6 Can I have VS.NET and the Visual Studio 6.0 installed on the same machine?&lt;br /&gt;&lt;/strong&gt;Yes! VS.Net works with the .Net framework, while VS6.0 works with MFC or the Windows API directly, for the most part. They can be installed and run on the same machine without any considerations.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q462q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.7 How should I check whether IIS is installed or not? &lt;/strong&gt;&lt;br /&gt;To verify if IIS is installed, go to your 'Add or Remove Programs' utility in the Control panel and click on the 'Add/Remove Windows Components' in the side menu.&lt;br /&gt;On XP Pro and below, you should see an item called "Internet Information Services (IIS)". If this is checked, IIS should be installed.&lt;br /&gt;On Win2K3, you'll see "Application Server". If this is checked, select it and then click 'Details'. Another form should open which will contain "Internet Information Services (IIS)". If it is checked, IIS should be installed.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q147q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;1.8 &lt;strong&gt;In Visual Studio .NET, how do I create a new ASP.NET application for an existing ASP.NET project?&lt;br /&gt;&lt;/strong&gt;First create an IIS application using the IIS MMC. Then in Visual Studio .NET, use the "New Project In Existing Folder" project template (at the end of the template list). It will first ask you for the project name (use the same one you created for the IIS application). Click OK button. Then enter in physical folder location.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q40q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.9 Why do I get the error message "Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request."?&lt;/strong&gt;&lt;br /&gt;By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account. For more details : &lt;/span&gt;&lt;a href="http://support.microsoft.com/default.aspx?kbid=315158&amp;amp;product=aspnet"&gt;&lt;span style="font-family:verdana;"&gt;FIX: ASP.NET Does Not Work with the Default ASPNET Account on a Domain Controller&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a name="#q146q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.10 In Visual Studio .NET, how do I create a new ASP.NET application which does not have a physical path under wwwroot?&lt;br /&gt;&lt;/strong&gt;You must first create an IIS application using the IIS MMC. Then in Visual Studio .NET, create a new ASP.NET application and give it the same name you used for the IIS application&lt;br /&gt;&lt;/span&gt;&lt;a name="#q508q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.11 Why do I get the "Unable to find script libruary 'WebUIValidation.js'" error ?&lt;/strong&gt;&lt;br /&gt;When you install the .Net framework on your web server, it installs some script files (including the above) under the root folder (usually "C:\inetput\wwwroot" if you do a default installation) . You can then find the above file at "C:\Inetpub\wwwroot\aspnet_client\system_web\1_1_4322", for example.&lt;br /&gt;The above problem could happen if you reconfigured your web root directory to be a different one after you installed ASP.Net in your web server. If that is the case, then run 'aspnet_regiis -c' (utility is under %windir%\Microsoft.NET\Framework\v1.1.4322, for example) or copy over manually the above script files into a similar sub-directory below your current web root directory. Also, if you look at the error message in detail, you will notice where the file is supposed to be.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q576q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.12 After installing .NET Framework SP1 the client side validations, or rather validator controls are not working? &lt;/strong&gt;&lt;br /&gt;The problem seems to be in the javascript file WebValidationUi.js in aspnet_client folder.The changes in that file prevent a page to be submitted. That could be the reason your javascript validations are not working. As a workaround, just copy the old WebValidateionUi.js over the new one.&lt;br /&gt;&lt;/span&gt;&lt;a name="#q580q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.13 How to Configure the ASP.NET Version to use for Each Application(developed using 1.0 or 1.1)?&lt;br /&gt;&lt;/strong&gt;To configure WebApp1 to use ASP.NET 1.0, follow these steps:&lt;br /&gt;Click Start, and then click Run.&lt;br /&gt;In the Open text box, type cmd, and then click OK.&lt;br /&gt;At the command prompt, locate the following directory: WindowsDirectory\Microsoft.NET\Framework\v1.0.3705\&lt;br /&gt;At the command prompt, type one of the following commands:&lt;br /&gt;To Install ASP.NET 1.0 recursively aspnet_regiis -s W3SVC/1/ROOT/WebApp1&lt;br /&gt;To Install ASP.NET 1.0 non-recursively aspnet_regiis -sn W3SVC/1/ROOT/WebApp1 To configure WebApp2 to use ASP.NET 1.1, follow these steps:&lt;br /&gt;Click Start, and then click Run.&lt;br /&gt;In the Open text box, type cmd, and then click OK.&lt;br /&gt;At the command prompt, locate the following directory: WindowsDirectory\Microsoft.NET\Framework\v1.1.4322\&lt;br /&gt;At the command prompt, type one of the following commands:&lt;br /&gt;To Install ASP.NET 1.1 recursively aspnet_regiis -s W3SVC/1/ROOT/WebApp2&lt;br /&gt;To Install ASP.NET 1.1 non-recursively aspnet_regiis -sn W3SVC/1/ROOT/WebApp2&lt;br /&gt;&lt;/span&gt;&lt;a name="#q581q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.14 How to Configure Different Versions of an ASP.NET Application Running on the Same Web Server?&lt;br /&gt;&lt;/strong&gt;Here is an expert from the KB article: &lt;/span&gt;&lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;816782"&gt;&lt;span style="font-family:verdana;"&gt;KB 816782&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;Find the ASP.NET Version Used for the Application View the script map for an ASP.NET application to determine the version of ASP.NET that the application uses. To view the script map for an ASP.NET application, follow these steps:&lt;br /&gt;Click Start, point to Programs, and then click Control Panel.&lt;br /&gt;Double-click Administrative Tools, and then double-click Internet Information Services (IIS).&lt;br /&gt;Expand local computer, expand Web Site, and then expand Default Web Site.&lt;br /&gt;Locate the folder that contains the ASP.NET application.&lt;br /&gt;Right-click the folder that contains the ASP.NET application, and then click Properties.&lt;br /&gt;Click the Directory tab, and then click Configuration. The Application Configuration dialog box opens.&lt;br /&gt;Click the Mappings tab, and then select an ASP.NET application extension, such as .asmx or .aspx. The Executable Path column of the dialog box lists the path to the ASP.NET ISAPI version that the application uses. By default, the ASP.NET ISAPI is installed in %WindowsDirectory%\Microsoft.NET\Framework\%versionNumber%. The version number in the path indicates the version number of the ASP.NET ISAPI that the application uses. The ASP.NET ISAPI version determines the version of the runtime that the application uses. Use Aspnet_regiis.exe to Update the Script MapTo make it easier to reconfigure the script map for an ASP.NET application, each installation of the .NET Framework is associated with a version of the ASP.NET IIS Registration tool (Aspnet_regiis.exe). You can use this tool to remap an ASP.NET application to the ASP.NET ISAPI version associated with the tool. Note Because Aspnet_regiis.exe is linked to a specific version of the .NET Framework, you must use the appropriate version of Aspnet_regiis.exe to reconfigure the script map for an ASP.NET application. Aspnet_regiis.exe only reconfigures the script map of an ASP.NET application to the ASP.NET ISAPI version associated with the tool Configure ASP.NET 1.0 for the ApplicationWhen ASP.NET 1.1 is configured on the root Web site, follow these steps to configure ASP.NET 1.0 for an application:&lt;br /&gt;Click Start, and then click Run. In the Open text box, type cmd, and then click OK.&lt;br /&gt;At the command prompt, locate the following directory path: %WindowsDirectory%\Microsoft.NET\Framework\v1.0.3705\&lt;br /&gt;Type the following command to configure the ASP.NET 1.0 application in IIS:&lt;br /&gt;aspnet_regiis -s w3svc/1/root/ApplicationName&lt;br /&gt;To remove ASP.NET 1.0 from this application, repeat steps 1and 2, and then type the following command:&lt;br /&gt;aspnet_regiis -k w3svc/1/root/ApplicationName&lt;br /&gt;Configure ASP.NET 1.1 for the Application When ASP.NET 1.0 is configured on the root Web site, follow these steps to configure ASP.NET 1.1 to run an application:&lt;br /&gt;Click Start, and then click Run. In the Open text box, type cmd, and then click OK.&lt;br /&gt;At the command prompt, locate the following directory path: %WindowsDirectory%\Microsoft.NET\Framework\v1.1.4322&lt;br /&gt;If ASP.NET 1.1 is not already registered, type the following command to register it: aspnet_regiis -ir Note The -ir option registers ASP.NET 1.1 without updating the scripts in IIS.&lt;br /&gt;Type the following to configure the ASP.NET 1.1 application in IIS:&lt;br /&gt;aspnet_regiis -s w3svc/1/root/ApplicationName&lt;br /&gt;To remove ASP.NET 1.1 from this application, repeat steps 1 and 2, and then type the following command:&lt;br /&gt;aspnet_regiis -k w3svc/1/root/ApplicationName&lt;br /&gt;&lt;/span&gt;&lt;a name="#q597q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.15 Why do I get error message "Internet Explorer cannot download MyPage.aspx from MyWebSite.com ..."?&lt;br /&gt;&lt;/strong&gt;This happens for example, when you try to export data to excel from a datagrid.&lt;br /&gt;The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:&lt;br /&gt;Pragma: no-cache&lt;br /&gt;Cache-control: no-cache,max-age=0,must-revalidate&lt;br /&gt;For more details refer &lt;/span&gt;&lt;a href="http://support.microsoft.com/default.aspx?scid=KB;EN-US;q316431"&gt;&lt;span style="font-family:verdana;"&gt;PRB: Internet Explorer Is Unable to Open Office Documents from an SSL Web Site &lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="#q336q"&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;1.16 Why do I get error message "Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. ..."?&lt;br /&gt;&lt;/strong&gt;You would get this error if the application mappings for ASP.NET file name extensions (such as .aspx) are not configured correctly in Microsoft Internet Information Services (IIS).&lt;br /&gt;To resolve this go to C:\Windows Directory\Microsoft.Net\Framework\Version and type aspnet_regiis -i to configure the required application mappings correctly &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-5069348062957112721?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/5069348062957112721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=5069348062957112721' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5069348062957112721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/5069348062957112721'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/faqs-on-aspnet-1.html' title='faqs on asp.net-1'/><author><name>.NET team</name><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-2557049885090666521.post-1365124757489614099</id><published>2008-02-15T14:04:00.000+05:30</published><updated>2008-02-15T14:42:25.987+05:30</updated><title type='text'>SQL Server Coding Conventions and Programming Guidelines</title><content type='html'>&lt;span style="font-family:verdana;"&gt;Here are some programming guidelines and best practices, keeping quality, performance and maintainability in mind. This list many not be complete at this moment, and will be constantly updated. BTW, special thanks to Tibor Karaszi (SQL Server MVP) and Linda (lindawie) for taking time to read this article and providing suggestions.&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Decide upon a database naming convention, standardize it across your organization, and be consistent in following it. It helps make your code more readable and understandable. &lt;/span&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Make sure you normalize your data at least to the 3rd normal form. At the same time, do not compromise on query performance. A little bit of denormalization helps queries perform faster. &lt;/span&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Write comments in your stored procedures, triggers and SQL batches generously, whenever something is not very obvious. This helps other programmers understand your code clearly. Don't worry about the length of the comments, as it won't impact the performance, unlike interpreted languages like ASP 2.0. &lt;/span&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not use SELECT * in your queries. Always write the required column names after the SELECT statement, like:&lt;/span&gt; &lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;SELECT CustomerID, CustomerFirstName, City&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Verdana;"&gt;This technique results in reduced disk I/O and better performance.&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Try to avoid server side cursors as much as possible. Always stick to a 'set-based approach' instead of a 'procedural approach' for accessing and manipulating data. Cursors can often be avoided by using SELECT statements instead.&lt;/span&gt; &lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span style="font-family:Verdana;"&gt;If a cursor is unavoidable, use a WHILE loop instead. I have personally tested and concluded that a WHILE loop is always faster than a cursor. But for a WHILE loop to replace a cursor you need a column (primary key or unique key) to identify each row uniquely. I personally believe every table must have a primary or unique key. &lt;a href="http://vyaskn.tripod.com/code.htm" target="_blank"&gt;&lt;span style="color:#000063;"&gt;Click here to see some examples of using a WHILE loop&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt;Avoid the creation of temporary tables while processing data as much as possible, as creating a temporary table means more disk I/O. Consider using advanced SQL, views, SQL Server 2000 table variable, or derived tables, instead of temporary tables.&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Try to avoid wildcard characters at the beginning of a word while searching using the LIKE keyword, as that results in an index scan, which defeats the purpose of an index. The following statement results in an index scan, while the second statement results in an index seek:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT LocationID FROM Locations WHERE Specialities LIKE '%pples'&lt;br /&gt;SELECT LocationID FROM Locations WHERE Specialities LIKE 'A%s'&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Also avoid searching using not equals operators (&amp;lt;&amp;gt; and NOT) as they result in table and index scans.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use 'Derived tables' wherever possible, as they perform better. Consider the following query to find the second highest salary from the Employees table:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT MIN(Salary)&lt;br /&gt;FROM Employees&lt;br /&gt;WHERE EmpID IN&lt;br /&gt;(&lt;br /&gt;SELECT TOP 2 EmpID&lt;br /&gt;FROM Employees&lt;br /&gt;ORDER BY Salary Desc&lt;br /&gt;)&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;The same query can be re-written using a derived table, as shown below, and it performs twice as fast as the above query:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT MIN(Salary)&lt;br /&gt;FROM&lt;br /&gt;(&lt;br /&gt;SELECT TOP 2 Salary&lt;br /&gt;FROM Employees&lt;br /&gt;ORDER BY Salary DESC&lt;br /&gt;) AS A&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;This is just an example, and your results might differ in different scenarios depending on the database design, indexes, volume of data, etc. So, test all the possible ways a query could be written and go with the most efficient one.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;While designing your database, design it keeping "performance" in mind. You can't really tune performance later, when your database is in production, as it involves rebuilding tables andindexes, re-writing queries, etc. Use the graphical execution plan in Query Analyzer or SHOWPLAN_TEXT or SHOWPLAN_ALL commands to analyze your queries. Make sure your queries do an "Index seek" instead of an "Index scan" or a "Table scan." A table scan or an index scan is a very bad thing and should be avoided where possible. Choose the right indexes on the right columns.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Prefix the table names with the owner's name, as this improves readability and avoids any unnecessary confusion. Microsoft SQL Server Books Online even states that qualifying table names with owner names helps in execution plan reuse, further boosting performance.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use SET NOCOUNT ON at the beginning of your SQL batches, stored procedures and triggers in production environments, as this suppresses messages like '(1 row(s) affected)' after executing INSERT, UPDATE, DELETE and SELECT statements. This improves the performance of stored procedures by reducing network traffic.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use the more readable ANSI-Standard Join clauses instead of the old style joins. With ANSI joins, the WHERE clause is used only for filtering data. Where as with older style joins, the WHERE clause handles both the join condition and filtering data. The first of the following two queries shows the old style join, while the second one shows the new ANSI join syntax:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT a.au_id, t.title&lt;br /&gt;FROM titles t, authors a, titleauthor ta&lt;br /&gt;WHERE&lt;br /&gt;a.au_id = ta.au_id AND&lt;br /&gt;ta.title_id = t.title_id AND&lt;br /&gt;t.title LIKE '%Computer%'&lt;br /&gt;&lt;br /&gt;SELECT a.au_id, t.title&lt;br /&gt;FROM authors a&lt;br /&gt;INNER JOIN&lt;br /&gt;titleauthor ta&lt;br /&gt;ON&lt;br /&gt;a.au_id = ta.au_id&lt;br /&gt;INNER JOIN&lt;br /&gt;titles t&lt;br /&gt;ON&lt;br /&gt;ta.title_id = t.title_id&lt;br /&gt;WHERE t.title LIKE '%Computer%' &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not prefix your stored procedure names with "sp_". The prefix sp_ is reserved for system stored procedure that ship with SQL Server. Whenever SQL Server encounters a procedure name starting with sp_, it first tries to locate the procedure in the master database, then it looks for any qualifiers (database, owner) provided, then it tries dbo as the owner. So you can really save time in locating the stored procedure by avoiding the "sp_" prefix.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Views are generally used to show specific data to specific users based on their interest. Views are also used to restrict access to the base tables by granting permission only on views. Yet another significant use of views is that they simplify your queries. Incorporate your frequently required, complicated joins and calculations into a view so that you don't have to repeat those joins/calculations in all your queries. Instead, just select from the view.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use User Defined Datatypes if a particular column repeats in a lot of your tables, so that the datatype of that column is consistent across all your tables.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not let your front-end applications query/manipulate the data directly using SELECT or INSERT/UPDATE/DELETE statements. Instead, create stored procedures, and let your applications access these stored procedures. This keeps the data access clean and consistent across all the modules of your application, and at the same time centralizing the business logic within the database.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Try not to use TEXT or NTEXT datatypes for storing large textual data. The TEXT datatype has some inherent problems associated with it. For example, you cannot directly write or update text data using the INSERT or UPDATE statements. Instead, you have to use special statements like READTEXT, WRITETEXT and UPDATETEXT. There are also a lot of bugs associated with replicating tables containing text columns. So, if you don't have to store more than 8KB of text, use CHAR(8000) or VARCHAR(8000) datatypes instead.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;If you have a choice, do not store binary or image files (Binary Large Objects or BLOBs) inside the database. Instead, store the path to the binary or image file in the database and use that as a pointer to the actual binary file stored elsewhere on a server. Retrieving and manipulating these large binary files is better performed outside the database, and after all, a database is not meant for storing files.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use the CHAR data type for a column only when the column is non-nullable. If a CHAR column is nullable, it is treated as a fixed length column in SQL Server 7.0+. So, a CHAR(100), when NULL, will eat up 100 bytes, resulting in space wastage. So, use VARCHAR(100) in this situation. Of course, variable length columns do have a very little processing overhead over fixed length columns. Carefully choose between CHAR and VARCHAR depending up on the length of the data you are going to store.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Avoid dynamic SQL statements as much as possible. Dynamic SQL tends to be slower than static SQL, as SQL Server must generate an execution plan every time at runtime. IF and CASE statements come in handy to avoid dynamic SQL. Another major disadvantage of using dynamic SQL is that it requires users to have direct access permissions on all accessed objects, like tables and views. Generally, users are given access to the stored procedures which reference the tables, but not directly on the tables. In this case, dynamic SQL will not work. Consider the following scenario where a user named 'dSQLuser' is added to the pubs database and is granted access to a procedure named 'dSQLproc', but not on any other tables in the pubs database. The procedure dSQLproc executes a direct SELECT on titles table and that works. The second statement runs the same SELECT on titles table, using dynamic SQL and it fails with the following error:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;Server: Msg 229, Level 14, State 5, Line 1&lt;br /&gt;SELECT permission denied on object 'titles', database 'pubs', owner 'dbo'.&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;To reproduce the above problem, use the following commands:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;sp_addlogin 'dSQLuser'&lt;br /&gt;GO&lt;br /&gt;sp_defaultdb 'dSQLuser', 'pubs'&lt;br /&gt;USE pubs&lt;br /&gt;GO&lt;br /&gt;sp_adduser 'dSQLUser', 'dSQLUser'&lt;br /&gt;GO&lt;br /&gt;CREATE PROC dSQLProc&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;SELECT * FROM titles WHERE title_id = 'BU1032' --This works&lt;br /&gt;DECLARE @str CHAR(100)&lt;br /&gt;SET @str = 'SELECT * FROM titles WHERE title_id = ''BU1032'''&lt;br /&gt;EXEC (@str) --This fails&lt;br /&gt;END&lt;br /&gt;GO&lt;br /&gt;GRANT EXEC ON dSQLProc TO dSQLuser&lt;br /&gt;GO&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Now login to the pubs database using the login dSQLuser and execute the procedure dSQLproc to see the problem.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Consider the following drawbacks before using the IDENTITY property for generating primary keys. IDENTITY is very much SQL Server specific, and you will have problems porting your database application to some other RDBMS. IDENTITY columns have other inherent problems. For example, IDENTITY columns can run out of numbers at some point, depending on the data type selected; numbers can't be reused automatically, after deleting rows; and replication and IDENTITY columns don't always get along well. &lt;/span&gt;&lt;/li&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Verdana;"&gt;So, come up with an algorithm to generate a primary key in the front-end or from within the inserting stored procedure. There still could be issues with generating your own primary keys too, like concurrency while generating the key, or running out of values. So, consider both options and go with the one that suits you best.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Minimize the use of NULLs, as they often confuse the front-end applications, unless the applications are coded intelligently to eliminate NULLs or convert the NULLs into some other form. Any expression that deals with NULL results in a NULL output. ISNULL and COALESCE functions are helpful in dealing with NULL values. Here's an example that explains the problem:&lt;br /&gt;&lt;br /&gt;Consider the following table, Customers which stores the names of the customers and the middle name can be NULL.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;CREATE TABLE Customers&lt;br /&gt;(&lt;br /&gt;FirstName varchar(20),&lt;br /&gt;MiddleName varchar(20),&lt;br /&gt;LastName varchar(20)&lt;br /&gt;)&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Now insert a customer into the table whose name is Tony Blair, without a middle name:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;INSERT INTO Customers&lt;br /&gt;(FirstName, MiddleName, LastName)&lt;br /&gt;VALUES ('Tony',NULL,'Blair')&lt;br /&gt;&lt;br /&gt;The following SELECT statement returns NULL, instead of the customer name:&lt;br /&gt;&lt;br /&gt;SELECT FirstName + ' ' + MiddleName + ' ' + LastName FROM Customers&lt;br /&gt;&lt;br /&gt;To avoid this problem, use ISNULL as shown below:&lt;br /&gt;&lt;br /&gt;SELECT FirstName + ' ' + ISNULL(MiddleName + ' ','') + LastName FROM Customers&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Use Unicode datatypes, like NCHAR, NVARCHAR, or NTEXT, if your database is going to store not just plain English characters, but a variety of characters used all over the world. Use these datatypes only when they are absolutely needed as they use twice as much space as non-Unicode datatypes.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Always use a column list in your INSERT statements. This helps in avoiding problems when the table structure changes (like adding or dropping a column). Here's an example which shows the problem.&lt;br /&gt;&lt;br /&gt;Consider the following table:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;CREATE TABLE EuropeanCountries&lt;br /&gt;(&lt;br /&gt;CountryID int PRIMARY KEY,&lt;br /&gt;CountryName varchar(25)&lt;br /&gt;)&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Here's an INSERT statement without a column list , that works perfectly:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;INSERT INTO EuropeanCountries&lt;br /&gt;VALUES (1, 'Ireland')&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Now, let's add a new column to this table:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;ALTER TABLE EuropeanCountries&lt;br /&gt;ADD EuroSupport bit&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;Now run the above INSERT statement. You get the following error from SQL Server:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;Server: Msg 213, Level 16, State 4, Line 1&lt;br /&gt;Insert Error: Column name or number of supplied values does not match table definition.&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;This problem can be avoided by writing an INSERT statement with a column list as shown below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;INSERT INTO EuropeanCountries&lt;br /&gt;(CountryID, CountryName)&lt;br /&gt;VALUES (1, 'England')&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Perform all your referential integrity checks and data validations using constraints (foreign key and check constraints) instead of triggers, as they are faster. Limit the use triggers only for auditing, custom tasks and validations that can not be performed using constraints. Constraints save you time as well, as you don't have to write code for these validations, allowing the RDBMS to do all the work for you.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Always access tables in the same order in all your stored procedures and triggers consistently. This helps in avoiding deadlocks. Other things to keep in mind to avoid deadlocks are: Keep your transactions as short as possible. Touch as few data as possible during a transaction. Never, ever wait for user input in the middle of a transaction. Do not use higher level locking hints or restrictive isolation levels unless they are absolutely needed. Make your front-end applications deadlock-intelligent, that is, these applications should be able to resubmit the transaction incase the previous transaction fails with error 1205. In your applications, process all the results returned by SQL Server immediately so that the locks on the processed rows are released, hence no blocking.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Offload tasks, like string manipulations, concatenations, row numbering, case conversions, type conversions etc., to the front-end applications if these operations are going to consume more CPU cycles on the database server. Also try to do basic validations in the front-end itself during data entry. This saves unnecessary network roundtrips.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;If back-end portability is your concern, stay away from bit manipulations with T-SQL, as this is very much RDBMS specific. Further, using bitmaps to represent different states of a particular entity conflicts with normalization rules.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Always add a @Debug parameter to your stored procedures. This can be of BIT data type. When a 1 is passed for this parameter, print all the intermediate results, variable contents using SELECT or PRINT statements and when 0 is passed do not print anything. This helps in quick debugging stored procedures, as you don't have to add and remove these PRINT/SELECT statements before and after troubleshooting problems.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not call functions repeatedly within your stored procedures, triggers, functions and batches. For example, you might need the length of a string variable in many places of your procedure, but don't call the LEN function whenever it's needed, instead, call the LEN function once, and store the result in a variable, for later use.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Make sure your stored procedures always return a value indicating their status. Standardize on the return values of stored procedures for success and failures. The RETURN statement is meant for returning the execution status only, but not data. If you need to return data, use OUTPUT parameters.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;If your stored procedure always returns a single row resultset, consider returning the resultset using OUTPUT parameters instead of a SELECT statement, as ADO handles output parameters faster than resultsets returned by SELECT statements.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Always check the global variable @@ERROR immediately after executing a data manipulation statement (like INSERT/UPDATE/DELETE), so that you can rollback the transaction in case of an error (@@ERROR will be greater than 0 in case of an error). This is important, because, by default, SQL Server will not rollback all the previous changes within a transaction if a particular statement fails. This behavior can be changed by executing SET XACT_ABORT ON. The @@ROWCOUNT variable also plays an important role in determining how many rows were affected by a previous data manipulation (also, retrieval) statement, and based on that you could choose to commit or rollback a particular transaction.&lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;To make SQL Statements more readable, start each clause on a new line and indent when needed. Following is an example:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT title_id, title&lt;br /&gt;FROM titles&lt;br /&gt;WHERE title LIKE '%Computer%' AND&lt;br /&gt;title LIKE '%cook%' &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Though we survived the Y2K, always store 4 digit years in dates (especially, when using cCHAR or INT datatype columns), instead of 2 digit years to avoid any confusion and problems. This is not a problem with DATETIME columns, as the century is stored even if you specify a 2 digit year. But it's always a good practice to specify 4 digit years even with DATETIME datatype columns. &lt;/span&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-family:Verdana;"&gt;As is true with any other programming language, do not use GOTO, or use it sparingly. Excessive usage of GOTO can lead to hard-to-read-and-understand code.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not forget to enforce unique constraints on your alternate keys.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Always be consistent with the usage of case in your code. On a case insensitive server, your code might work fine, but it will fail on a case sensitive SQL Server if your code is not consistent in case. For example, if you create a table in SQL Server or a database that has a case-sensitive or binary sort order, all references to the table must use the same case that was specified in the CREATE TABLE statement. If you name the table as 'MyTable' in the CREATE TABLE statement and use 'mytable' in the SELECT statement, you get an 'object not found' error.&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Though T-SQL has no concept of constants (like the ones in the C language), variables can serve the same purpose. Using variables instead of constant values within your queries improves readability and maintainability of your code. Consider the following example:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier;"&gt;SELECT OrderID, OrderDate&lt;br /&gt;FROM Orders&lt;br /&gt;WHERE OrderStatus IN (5,6)&lt;/span&gt; &lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;&lt;br /&gt;The same query can be re-written in a mode readable form as shown below:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;DECLARE @ORDER_DELIVERED, @ORDER_PENDING&lt;br /&gt;SELECT @ORDER_DELIVERED = 5, @ORDER_PENDING = 6&lt;br /&gt;&lt;br /&gt;SELECT OrderID, OrderDate&lt;br /&gt;FROM Orders&lt;br /&gt;WHERE OrderStatus IN (@ORDER_DELIVERED, @ORDER_PENDING)&lt;/span&gt; &lt;li&gt;&lt;span style="font-family:Verdana;"&gt;Do not use column numbers in the ORDER BY clause. Consider the following example in which the second query is more readable than the first one:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;SELECT OrderID, OrderDate&lt;br /&gt;FROM Orders&lt;br /&gt;ORDER BY 2&lt;br /&gt;&lt;br /&gt;SELECT OrderID, OrderDate&lt;br /&gt;FROM Orders&lt;br /&gt;ORDER BY OrderDate&lt;/span&gt; &lt;/li&gt;&lt;p&gt;&lt;span style="font-family:Verdana;"&gt;Well, this is all for now folks.&lt;br /&gt;Happy database programming!&lt;/p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-1365124757489614099?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/1365124757489614099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=1365124757489614099' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1365124757489614099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/1365124757489614099'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/sql-server-coding-conventions-and.html' title='SQL Server Coding Conventions and Programming Guidelines'/><author><name>.NET team</name><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-2557049885090666521.post-100095646673143342</id><published>2008-02-14T15:42:00.000+05:30</published><updated>2008-12-11T19:07:15.980+05:30</updated><title type='text'>Multithreading in C# at Glance</title><content type='html'>&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_dTCM5Vgc40g/R7QWD7qdu3I/AAAAAAAAAXQ/WLZStssrh5g/s1600-h/juggler.jpg"&gt;&lt;span style="font-family:verdana;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5166778929312021362" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_dTCM5Vgc40g/R7QWD7qdu3I/AAAAAAAAAXQ/WLZStssrh5g/s320/juggler.jpg" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; In this article I will attempt to give an introductory discussion on threading, why it is used, and how you use it in .NET. I hope to once and for all unveil the mystery behind multithreading, and in explaining it, help avert potential threading disasters in your code.&lt;br /&gt;&lt;strong&gt;What is a thread?&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Every application runs with at least one thread. So what is a thread? A thread is nothing more than a process. My guess is that the word thread comes from the Greek mythology of supernatural Muses weaving threads on a loom, where each thread represents a path in time of someone's life. If you mess with that thread, then you disturb the fabric of life or change the process of life. On the computer, a thread is a process moving through time. The process performs sets of sequential steps, each step executing a line of code. Because the steps are sequential, each step takes a given amount of time. The time it takes to complete a series of steps is the sum of the time it takes to perform each programming step.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;What are multithreaded applications?&lt;br /&gt;&lt;/strong&gt;For a long time, most programming applications (except for embedded system programs) were single-threaded. That means there was only one thread in the entire application. You could never do computation A until completing computation B. A program starts at step 1 and continues sequentially (step 2, step 3, step 4) until it hits the final step (call it step 10). A multithreaded application allows you to run several threads, each thread running in its own process. So theoretically you can run step 1 in one thread and at the same time run step 2 in another thread. At the same time you could run step 3 in its own thread, and even step 4 in its own thread. Hence step 1, step 2, step 3, and step 4 would run concurrently. Theoretically, if all four steps took about the same time, you could finish your program in a quarter of the time it takes to run a single thread (assuming you had a 4 processor machine). So why isn't every program multithreaded? Because along with speed, you face complexity. Imagine if step 1 somehow depends on the information in step 2. The program might not run correctly if step 1 finishes calculating before step 2 or visa versa.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;When to Thread&lt;br /&gt;&lt;/strong&gt;Multiple threading is most often used in situations where you want programs to run more efficiently. For example, let's say your Window Form program contains a method (call it method_A) inside it that takes more than a second to run and needs to run repetitively. Well, if the entire program ran in a single thread, you would notice times when button presses didn't work correctly, or your typing was a bit sluggish. If method_A was computationally intensive enough, you might even notice certain parts of your Window Form not working at all. This unacceptable program behavior is a sure sign that you need multithreading in your program. Another common scenario where you would need threading is in a messaging system. If you have numerous messages being sent into your application, you need to capture them at the same time your main processing program is running and distribute them appropriately. You can't efficiently capture a series of messages at the same time you are doing any heavy processing, because otherwise you may miss messages. Multiple threading can also be used in an assembly line fashion where several processes run simultaneously. For example once process collects data in a thread, one process filters the data, and one process matches the data against a database. Each of these scenarios are common uses for multithreading and will significantly improve performance of similar applications running in a single thread.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;When not to Thread&lt;br /&gt;&lt;/strong&gt;It is possible that when a beginning programmer first learns threading, they may be fascinated with the possibility of using threading in their program. They may actually become thread-happy. Let me elaborate:&lt;br /&gt;Day 1) Programmer learns the that they can spawn a thread and begins creating a single new thread in their program, Cool!&lt;br /&gt;Day 2) Programmer says, " I can make this even more efficient by spawning other threads in parts of my program!"&lt;br /&gt;Day 3) P: "Wow, I can even fork threads within threads and REALLY improve efficiency!!"&lt;br /&gt;Day 4) P: "I seem to be getting some odd results, but that's okay, we'll just ignore them for now." Day 5) "Hmmmm, sometimes my widgetX variable has a value, but other times it never seems to get set at all, must be my computer isn't working, I'll just run the debugger".&lt;br /&gt;Day 9) "This darn (stronger language) program is jumping all over the place!! I can't figure out what is going on!"&lt;br /&gt;Week 2) Sometimes the program just sits there and does absolutely nothing! H-E-L-P!!!!!&lt;br /&gt;Sound familiar? Almost anyone who has attempted to design a multi-threaded program for the first time, even with good design knowledge of threading, has probably experienced at least 1 or 2 of these daily bullet points. I am not insinuating that threading is a bad thing, I'm just pointing out that in the process of creating threading efficiency in your programs, be very, very careful. Because unlike a single threaded program, you are handling many processes at the same time, and multiple processes, with multiple dependent variables, can be very tricky to follow. Think of multithreading like you would think of juggling. Juggling a single ball in your hand (although kind of boring) is fairly simple. However, if you are challenged to put two of those balls in the air, the task is a bit more difficult. 3, 4, and 5, balls are progressively more difficult. As the ball count increases, you have a better and better chance of really dropping the ball. Juggling a lot of balls at once requires knowledge, skill, and precise timing. So does multiple threading.&lt;br /&gt;&lt;strong&gt;Problems with Threading&lt;/strong&gt;&lt;br /&gt;If every process in your program was mutually exclusive - that is, no process depended in any way upon another, then multiple threading would be very easy and very few problems would occur. Each process would run along in its own happy course and not bother the other processes. However, when more than one process needs to read or write the memory used by other processes, problems can occur. For example let's say there are two processes, process #1 and process #2. Both processes share variable X. If thread process #1 writes variable X with the value 5 first and thread process #2 writes variable X with value -3 next, the final value of X is -3. However if process #2 writes variable X with value -3 first and then process #1 writes variable X with value 5, the final value of X is 5. So you see, if the process that allows you to set X has no knowledge of process #1 or process #2, X can end up with different final values depending upon which thread got to X first. In a single threaded program, there is no way this could happen, because everything follows in sequence. In a single threaded program, since no processes are running in parallel, X is always set by method #1 first, (if it is called first) and then set by method #2. There are no surprises in a single threaded program, it's just step by step. With a mulithreaded program, two threads can enter a piece of code at the same time, and wreak havoc on the results. The problem with threads is that you need some way to control one thread accessing a shared piece of memory while another thread running at the same time is allowed to enter the same code and manipulate the shared data.&lt;br /&gt;&lt;strong&gt;Thread Safety&lt;/strong&gt;&lt;br /&gt;Imagine if every time you juggled three balls, the ball in the air, by some freak of nature, was never allowed to reach your right hand until the ball already sitting in your right hand was thrown. Boy, would juggling be a lot easier! This is what thread safety is all about. In our program we force one thread to wait inside our code block while the other thread is finishing its business. This activity, known as thread blocking or synchronizing threads, allows us to control the timing of simultaneous threads running inside our program. In C# we lock on a particular part of memory (usually an instance of an object) and don't allow any thread to enter code of this object's memory until another thread is done using the object. By now you are probably thirsting for a code example, so here you go.&lt;br /&gt;Let's take a look at a two-threaded scenario. In our example, we will create two threads in C#: Thread 1 and Thread 2, both running in their own while loop. The threads won't do anything useful, they will just print out a message saying which thread they are part of. We will utilize a shared memory class member called _threadOutput. _threadOutput will be assigned a message based upon the thread in which it is running. Listing #1 shows the two threads contained in DisplayThread1 and DisplayThread2 respectively.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;Listing 1 - Creating two threads sharing a common variable in memory&lt;br /&gt;&lt;/strong&gt;// shared memory variable between the two threads &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;// used to indicate which thread we are in private string _threadOutput = "";&lt;br /&gt;/// &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 1: Loop continuously,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 1: Displays that we are in thread 1 &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// &lt;/summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;void DisplayThread1() &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;while (_stopThreads == false) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Display Thread 1");&lt;br /&gt;// Assign the shared memory to a message about thread #1 _threadOutput = "Hello Thread1";&lt;br /&gt;Thread.Sleep(1000); // simulate a lot of processing&lt;br /&gt;// tell the user what thread we are in thread #1, and display shared memory &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Thread 1 Output --&gt; {0}", _threadOutput);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;}&lt;br /&gt;// &lt;summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 2: Loop continuously,&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 2: Displays that we are in thread 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// &lt;/summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;void DisplayThread2() &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;while (_stopThreads == false)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Display Thread 2");&lt;br /&gt;// Assign the shared memory to a message about thread #2 _threadOutput = "Hello Thread2";&lt;br /&gt;Thread.Sleep(1000); // simulate a lot of processing&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// tell the user we are in thread #2 &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Thread 2 Output --&gt; {0}", _threadOutput);&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;}&lt;br /&gt;Class1()&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// construct two threads for our demonstration;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Thread thread1 = new Thread(new ThreadStart(DisplayThread1));&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Thread thread2 = new Thread(new ThreadStart(DisplayThread2)); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// start them &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;thread1.Start(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;thread2.Start();&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;The results of this code is shown in figure 2. Look carefully at the results.&lt;/strong&gt; You will notice that the program gives some surprising output(if we were looking at this from a single-threaded mindset). Although we clearly assigned _threadOutput to a string with a number corresponding to the thread to which it belongs, that is not what it looks like in the console:&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;p&gt;&lt;img id="BLOGGER_PHOTO_ID_5166792424099265426" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R7QiVbqdu5I/AAAAAAAAAXg/i0s7JNatypI/s320/ThreadOutput1.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We would expect to see the following from our code&lt;br /&gt;Thread 1 Output --&gt; Hello Thread 1 and Thread 2 Output --&gt; Hello Thread 2, but for the most part, the results are completely unpredictable.&lt;br /&gt;Sometimes we see Thread 2 Output --&gt; Hello Thread 1 and Thread 1 Output --&gt; Hello Thread 2. The thread output does not match the code! Even though, we look at the code and follow it with our eyes, _threadOutput = "Hello Thread 2", Sleep, Write "Thread 2 --&gt; Hello Thread 2", this sequence we expect does not necessarily produce the final result.&lt;br /&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br /&gt;The reason we see the results we do is because in a multithreaded program such as this one, the code theoretically is executing the two methods DisplayThread1 and DisplayThread2, simultaneously. Each method shares the variable, _threadOutput. So it is possible that although _threadOutput is assigned a value "Hello Thread1" in thread #1 and displays _threadOutput two lines later to the console, that somewhere in between the time thread #1 assigns it and displays it, thread #2 assigns _threadOutput the value "Hello Thread2". Not only are these strange results, possible, they are quite frequent as seen in the output shown in figure 2. This painful threading problem is an all too common bug in thread programming known as a race condition. This example is a very simple example of the well-known threading problem. It is possible for this problem to be hidden from the programmer much more indirectly such as through referenced variables or collections pointing to thread-unsafe variables. Although in figure 2 the symptoms are blatant, a race condition can appear much more rarely and be intermittent once a minute, once an hour, or appear three days later. The race is probably the programmer's worst nightmare because of its infrequency and because it can be very very hard to reproduce.&lt;br /&gt;&lt;strong&gt;Winning the Race&lt;/strong&gt;&lt;br /&gt;The best way to avoid race conditions is to write thread-safe code. If your code is thread-safe, you can prevent some nasty threading issues from cropping up. There are several defenses for writing thread-safe code. One is to share memory as little as possible. If you create an instance of a class, and it runs in one thread, and then you create another instance of the same class, and it runs in another thread, the classes are thread safe as long as they don't contain any static variables. The two classes each create their own memory for their own fields, hence no shared memory. If you do have static variables in your class or the instance of your class is shared by several other threads, then you must find a way to make sure one thread cannot use the memory of that variable until the other class is done using it. The way we prevent one thread from effecting the memory of the other class while one is occupied with that memory is called locking. C# allows us to lock our code with either a Monitor class or a lock { } construct. (The lock construct actually internally implements the Monitor class through a try-finally block, but it hides these details from the programmer). In our example in listing 1, we can lock the sections of code from the point in which we populate the shared _threadOutput variable all the way to the actual output to the console. We lock our critical section of code in both threads so we don't have a race in one or the other. The quickest and dirtiest way to lock inside a method is to lock on the this pointer. Locking on the this pointer will lock on the entire class instance, so any thread trying to modify a field of the class while inside the lock, will be blocked. Blocking means that the thread trying to change the variable will sit and wait until the lock is released on the locked thread. The thread is released from the lock upon reaching the last bracket in the lock { } construct.&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Listing 2 - Synchronizing two Threads by locking them&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 1, Displays that we are in thread 1 (locked)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// &lt;/summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;void DisplayThread1()&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;while (_stopThreads == false)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// lock on the current instance of the class for thread #1 &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;lock (this) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Display Thread 1"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;_threadOutput = "Hello Thread1";&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Thread.Sleep(1000); // simulate a lot of processing &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// tell the user what thread we are in thread #1 &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Thread 1 Output --&gt; {0}", _threadOutput); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;} // lock released for thread #1 here&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// Thread 1, Displays that we are in thread 1 (locked)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;/// &lt;/summary&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;void DisplayThread2() &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;while (_stopThreads == false) &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="color:#ff6600;"&gt;{&lt;br /&gt;// lock on the current instance of the class for thread #2 &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;lock (this) &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Console.WriteLine("Display Thread 2"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;_threadOutput = "Hello Thread2"; &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;Thread.Sleep(1000); // simulate a lot of processing&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;// tell the user what thread we are in thread #1 Console.WriteLine("Thread 2 Output --&gt; {0}", _threadOutput);&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;} // lock released for thread #2 here &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;} &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff6600;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The results of locking the two threads is shown in figure 3. Note that all thread output is nicely synchronized. You always get a result saying Thread 1 Output --&gt; Hello Thread 1 and Thread 2 Output --&gt; Hello Thread 2. Note, however, that thread locking does come at a price. When you lock a thread, you force the other thread to wait until the lock is released. In essence, you've slowed down the program, because while the other thread is waiting to use the shared memory, the first thread isn't doing anything in the program. Therefore you need to use locks sparingly; don't just go and lock every method you have in your code if they are not involved in shared memory. Also be careful when you use locks, because you don't want to get into the situation where thread #1 is waiting for a lock to be released by thread #2, and thread #2 is waiting for a lock to be released by thread #1. When this situation happens, both threads are blocked and the program appears frozen. This situation is known as deadlock and is almost as bad a situation as a race condition, because it can also happen at unpredictable, intermittent periods in the program.&lt;br /&gt;&lt;img id="BLOGGER_PHOTO_ID_5166792424099265426" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_dTCM5Vgc40g/R7QiVbqdu5I/AAAAAAAAAXg/i0s7JNatypI/s320/ThreadOutput2.jpg" border="0" /&gt;Figure 3 - Synchronizing the dual thread program using locks&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;&lt;strong&gt;Alternative Solution&lt;br /&gt;&lt;/strong&gt;.NET provides many mechanisms to help you control threads. Another way to keep a thread blocked while another thread is processing a piece of shared memory is to use an AutoResetEvent. The AutoResetEvent class has two methods, Set and WaitOne. These two methods can be used together for controlling the blocking of a thread. When an AutoResetEvent is initialized with false, the program will stop at the line of code that calls WaitOne until the Set method is called on the AutoResetEvent. After the Set method is executed on the AutoResetEvent, the thread becomes unblocked and is allowed to proceed past WaitOne. The next time WaitOne is called, it has automatically been reset, so the program will again wait (block) at the line of code in which the WaitOne method is executing. You can use this "stop and trigger" mechanism to block on one thread until another thread is ready to free the blocked thread by calling Set. Listing 3 shows our same two threads using the AutoResetEvent to block each other while the block thread waits and the unblocked thread executes to display _threadOutput to the Console. Initially, _blockThread1 is initialized to signal false, while _blockThread2 is initialized to signal true. This means that _blockThread2 will be allowed to proceed through the WaitOne call the first time through the loop in DisplayThread_2, while _blockThread1 will block on its WaitOne call in DisplayThread_1. When the _blockThread2 reaches the end of the loop in thread 2, it signals _blockThread1 by calling Set in order to release thread 1 from its block. Thread 2 then waits in its WaitOne call until Thread 1 reaches the end of its loop and calls Set on _blockThread2. The Set called in Thread 1 releases the block on thread 2 and the process starts again. Note that if we had set both AutoResetEvents (_blockThread1 and _blockThread2) initially to signal false, then both threads would be waiting to proceed through the loop without any chance to trigger each other, and we would experience a deadlock.&lt;br /&gt;The output produced by listing 3 is the same output as our locking code, shown in figure 3, but the AutoResetEvent gives us some more dynamic control over how one thread can notify another thread when the current thread is done processing.&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_dTCM5Vgc40g/R7Ubcbqdu6I/AAAAAAAAAXo/aZeAef4gfD0/s1600-h/logo.gif"&gt;&lt;img id="BLOGGER_PHOTO_ID_5167066322753665954" style="CURSOR: hand" alt="" src="http://2.bp.blogspot.com/_dTCM5Vgc40g/R7Ubcbqdu6I/AAAAAAAAAXo/aZeAef4gfD0/s320/logo.gif" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-100095646673143342?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/100095646673143342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=100095646673143342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/100095646673143342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/100095646673143342'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/multithreading-in-c-at-glance.html' title='Multithreading in C# at Glance'/><author><name>.NET team</name><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://3.bp.blogspot.com/_dTCM5Vgc40g/R7QWD7qdu3I/AAAAAAAAAXQ/WLZStssrh5g/s72-c/juggler.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2557049885090666521.post-3905242019660103410</id><published>2008-02-12T12:07:00.000+05:30</published><updated>2008-02-12T12:35:08.339+05:30</updated><title type='text'>.Net COM Interop</title><content type='html'>&lt;span style="font-family:verdana;"&gt;The ultimate goal of COM Interop is to provide access to the existing &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;COM components&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; without requiring that the original component be modified. This tries to make the .NET types equivalent to the COM Types.&lt;br /&gt;&lt;strong&gt;COM Interop and Marshalling:&lt;/strong&gt;&lt;br /&gt;COM had a mechanism of marshalling and un-marshalling to convert between the source and target &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;data types&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;. This is now totally covered in COM Interop using RCW or Runtime Callable Wrapper. This automatically converts the .Net data types to the corresponding COM data types.&lt;br /&gt;RegAsm and tlbimp in COM Interop&lt;br /&gt;In addition, COM Interop allows COM developers to access managed objects as easily as they access other COM objects. It provides a specialized utility (RegAsm.exe) that exports the managed types into a type library and registers the managed component as a traditional COM component. At run time, the &lt;/span&gt;&lt;span style="font-family:verdana;"&gt;common language runtime&lt;/span&gt;&lt;span style="font-family:verdana;"&gt; marshals data between COM objects and managed objects as needed.&lt;br /&gt;This tutorial shows how C# can use COM objects to develop applications. First thing to be done is the creation of wrapper class for the selected COM object. It can be done manually through the command line application called TlbImp.exe (Type Library Importer). This utility converts COM type library to the .NET Framework metadata. This procedure can be done automatically through the .NET environment. We just need to add reference to the COM object to our C# project. So, type in .NET command line next string: tlbimp $WindowsPath$\system32\&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;quartz&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;.dll /out: quartzNET.dll. This command will create a new dll with types that are compatible with any of Managed .NET languages. Now we can add this dll to our C# project or compile our C# file with additional feature "/r quartzNET.dll".&lt;br /&gt;&lt;strong&gt;The following is an example of usage this COM object in C# managed code:&lt;/strong&gt;&lt;br /&gt;quartzNET.FilgraphManager manager = new quartzNET.FilgraphManagerClass();quartzNET.IMediaControl mc = (quartzNET.IMediaControl)manager;mc.RenderFile(args[0]);mc.Run();// Wait for completion.Console.WriteLine("Press Enter to continue."); Console.ReadLine();&lt;br /&gt;Here is the MediaControl object, which was created in COM. This application gets a name of video file that we want to play from command line and shows it. So, this is a simple example of usage COM Interop. To compile an attached example we just need this quartzNET.dll (is attached too) and .NET command line. Type here next command csc InteropSample.cs /r:quartzNET.dll. It must create an executable file, but it can be run using command line, just type InteroPsample.exe some.avi. So, it opens a console application and also runs a standard Windows media player control to play the video. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-3905242019660103410?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/3905242019660103410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=3905242019660103410' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3905242019660103410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/3905242019660103410'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/net-com-interop.html' title='.Net COM Interop'/><author><name>.NET team</name><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-2557049885090666521.post-4614186831325267755</id><published>2008-02-08T18:01:00.000+05:30</published><updated>2008-02-12T12:38:19.412+05:30</updated><title type='text'>Create 3D DirectX Animation in C# and .NET</title><content type='html'>&lt;span style="font-family:verdana;"&gt;It has always been a little painful creating 3D animation using Microsoft DirectX... until now. &lt;/span&gt;&lt;a href="http://www.truevision3d.com/downloads.php"&gt;&lt;span style="font-family:verdana;"&gt;True Vision 3D&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; has created a nice wrapper around DirectX 9 to simplify the task of doing animation and game development in .NET. With this well defined game engine, you can get going creating moving objects right away. This article is based on a tutorial written by the author &lt;/span&gt;&lt;a href="http://www.developer.com/net/csharp/article.php/3582636"&gt;&lt;span style="font-family:verdana;"&gt;Fatima Ahmed&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; describing how to use True Vision to create a furnished room.&lt;br /&gt;Understanding the 3D World&lt;br /&gt;There are a few concepts you will need to understand before tackling the world of 3D animation. Much of 3D design is based on the concept of meshes. Meshes are these wire frames described in terms of 3d vectors. You can think of a mesh as a bent up piece of chicken wire that forms the shape of the desirable object. A mesh is rendered from its vector components into a solid object using some fancy algorithms handled by Direct X. In order to give the "chicken wire" a more realistic look, the wire mesh is covered with a texture. Textures are simply bitmaps that fill in the polygons in the 3D mesh. In additions to textures and meshes, the 3D world has the concept of lighting in order to give objects an additional dimension. Colors in the scene are made lighter or darker to give the illusion of different concentrations of light. Developers often use programming tools such as 3D Studio, Lightwave 3D, or SoftImage to create meshes, textures, and other aspects of game development.&lt;br /&gt;Thinking in True Vision&lt;br /&gt;The concept behind DirectX (and wrapped nicely by True Vision) is that you create all these meshes as objects in your scene, and rotate, translate, color, or illuminate them separately. Anotherwords, the steps to animating meshes are this: change the meshes in your scene, render the whole scene. Then repeat: change the meshes in your scene, render the whole scene. When do you change the scene? You can change the scene in response to user input, or in response to a timer, or whatever event in your application is suitable for triggering a change.&lt;br /&gt;The Program Structure&lt;br /&gt;The application initializes the True Vision Engine at the time of the load event of the Windows Form. Inside the load event handler, we create all our mesh objects. Then we kick off the main loop. The main loop, which is common to all directx applications, just spins a loop that continously renders the scene filled with meshes. Rendering is handled in 3 steps: step 1) clear the previously rendered objects. step 2) render the new scene in memory 3) display the newly rendered scene on the screen. These steps continue to loop at a predetermined frame rate. The loop is exited only after the program sets the loop variable to false. In our program the loop variable is set to false when the user presses the exit button or closes the form.&lt;br /&gt;Animation&lt;br /&gt;In order to see some interesting animation from our mesh objects, we have to transform them. We added a routine inside the rendering loop that rotates some of the objects in our scene. You can rotate any mesh object in the scene that you want using True Vision, but we chose to rotate the dice and the sunglasses. This strange rotation of objects in the room gives you the illusion that the room is haunted. To animate, we just add a line inside the rendering loop that calls the method RotateSomeObjects. This method changes the position of the sunglasses and dice each time through the loop. At the current frame rate, the dice and sunglasses look like they are spinning.&lt;br /&gt;The Code&lt;br /&gt;Let's take a more detailed look at the code to understand what we talked about so far. Initialization takes place in the form load event. The first method, SetupTheInitialScene, sets up the engine, and creates the scene and all the mesh objects. The Main_Loop call starts the loop and asks the scene to render itself every time through the loop.&lt;br /&gt;Listing 1 - Loading the Scene and starting the Main Loop&lt;br /&gt;private void Form1_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;// set up the initial scene&lt;br /&gt;SetupTheInitialScene();&lt;br /&gt;// show the form and give it focus&lt;br /&gt;this.Show();&lt;br /&gt;this.Focus();&lt;br /&gt;// start up the main loop, setting the loop guard to ON&lt;br /&gt;DoLoop = true;&lt;br /&gt;Main_Loop();&lt;br /&gt;}&lt;br /&gt;Let's take a look at these two methods. The SetupTheInitialScene in the form first calls the InitializeTrueVision method in our form which initializes the engine. Then the SetupTheInitialScene method sets up the lighting and textures to be used by the mesh shapes. Finally SetupTheInitialScene creates the walls and mesh shapes needed to render the scene as shown in listing 2:&lt;br /&gt;Listing 2 - Setup the scene and create the mesh shapes in the room&lt;br /&gt;private void SetupTheInitialScene(){// initialize true vision details InitializeTrueVision();// create a new scene _scene = new TVScene();// set the scene background color _scene.SetSceneBackGround(0f, 0.3f, 0.9f);// set the lighting of the scene SetupLighting();// Load Textures LoadTextures();// create wall CreateWalls();//Set the position of the room mesh _meshRoom.SetPosition(x_move, y_move, z_move);// create different shapes in the room CreateMeshShapes();}&lt;br /&gt;The InitializeTrueVision called from SetupTheInitialScene, initializes the true vision engine and sets up texture and mesh path information. This method also points the engine to render inside the picturebox in our form. As you can see, initialization of the True Vision framework is pretty sttraightfoward with just a few lines of code.&lt;br /&gt;Listing 3 - Initializes the True Vision Engine&lt;br /&gt;void InitializeTrueVision(){// create a new game engineTV = new TVEngine();// set the engine to point the picture box so all rendering will// occur inside the picture box in the formTV.Init3DWindowedMode(this.pictureBox1.Handle.ToInt32(), true);//This is the path where our media (texture and meshes) files are placedTV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath);// set the rotation angle to be in degreesTV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);// We want to see the frames per secondTV.DisplayFPS = true;}&lt;br /&gt;The LoadTextures method called from SetupTheInitialScene brings in all the textures used in the scene as shown in listing 4. Textures are bitmaps such as jpg or bmp files. You only need to refer to the texture file's relative path because in Listing 3 we already told the engine what the search path for media would be. The call which loads the texture assigns a keyword so the texture can be referred to in the code by the keyword. For example the marble.jpg texture file loaded into the scene is assigned the keyword "marble".&lt;br /&gt;Listing 4 - Loading the Textures into the Scene&lt;br /&gt;private void LoadTextures(){ _scene.LoadTexture("textures\\marble.jpg", -1, -1, "marble"); _scene.LoadTexture("textures\\cinder.bmp", -1, -1, "wood"); _scene.LoadTexture("textures\\granite.bmp", -1, -1, "granite"); _scene.LoadTexture("textures\\metal.bmp", -1, -1, "metal"); _scene.LoadTexture("textures\\sandstone.bmp", -1, -1, "sandstone"); _scene.LoadTexture("textures\\oldrock.bmp", -1, -1, "oldrock");}&lt;br /&gt;Now that we have our textures, we are ready to create our mesh shapes. First we will create the room walls. Lucky for us, the True Vision engine has built-in methods to handle the creating of walls as shown in listing 5. We simply use the AddWall3D method. This method takes the texture as its first parameter. The texture id is looked up through the keyword we assigned in listing 4. Our walls are all cinder blocks, so we will bring in the cinder block texture. The next 4 parameters in the AddWall3D method specify the x and z 3d coordinate positions defining the wall rectangle. The last two parameters specify the tile dimensions of the texture. There is a separate call to draw the floor called AddFloor and before you know it we have a room! Listing 5 shows the calls for creating a mesh room and figure 2 shows the rendered result. (Note the room isn't actually rendered until the Main_Loop).&lt;br /&gt;Listing 5 - Creating the room walls using the True Vision Engine&lt;br /&gt;private void CreateWalls(){&lt;br /&gt;// create a new mesh object and call it "room_meshRoom = (TVMeshClass)_scene.CreateMeshBuilder("room");&lt;br /&gt;// add the walls to the room_meshRoom.AddWall3D(global.GetTex("cinder"), 350.0f, -350.0f, -350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);_meshRoom.AddWall3D(global.GetTex("cinder"), -350.0f, -350.0f, -350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);_meshRoom.AddWall3D(global.GetTex("cinder"), -350.0f, 350.0f, 350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);_meshRoom.AddWall3D(global.GetTex("cinder"), 350.0f, 350.0f, 350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);_meshRoom.AddFloor(global.GetTex("sandstone"), -350.0f, -350 - 0f, 350.0f, 350.0f, -50.0f, 10.0f, 10.0f, true, false);}&lt;br /&gt;Now let's see how to create all the cool shapes in our room. Listing 6 creates all the shapes in our room: 2 chairs, 2 dice, a table, a sphere, and a pair of sunglasses.&lt;br /&gt;Listing 6 - Creating the interesting mesh shapes inside the Room&lt;br /&gt;In order to create a shape, we just need to load an existing mesh object from a file, perhaps give it a texture, and set its position in the room. The mesh file format for direct x is the x file format (sounds a bit like TV show). The extension of this format is .x and is used for creating games for the X-Box and other DirectX applications. True Vision also excepts the 3d studio (3ds) format, but our example uses X meshes. Let's see how we create a mesh object for the table. First we create a mesh object, this can be done directly from the scene the CreateMeshBuilder method. Next we load the X file from our meshes directory and place it at the desired x,y,z coordinates in the room (using SetPosition). We want to size and rearrange the table a bit, so we scale it by a factor of 3 and turn it 25 degrees. Finally we apply the sandstone texture to the table by calling SetTexture as in Listing 7.&lt;br /&gt;Conclusion&lt;br /&gt;DirectX has never been easy to program. The True Vision library makes a great attempt at simplifying the use of DirectX 9 with a well thought out .NET library. In this article we have shown you how to use True Vision's engine to create a scene and render it to the screen. We have given you some insight into how to create 3D animation, and we have shown you how you can take advantage of True Visions Input Engine to control the animation. Hopefully this article will get you started in creating your own great games or creative visions in the world of .NET.&lt;br /&gt;References&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.truevision3d.com/downloads.php"&gt;&lt;span style="font-family:verdana;"&gt;True Vision 3D SDK 6,2&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.developer.com/net/csharp/article.php/3582636"&gt;&lt;span style="font-family:verdana;"&gt;Creating an Interactive 3D World with C# and .NET&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;"&gt; by Fatima Ahmed&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2557049885090666521-4614186831325267755?l=newcsharp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://newcsharp.blogspot.com/feeds/4614186831325267755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2557049885090666521&amp;postID=4614186831325267755' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4614186831325267755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2557049885090666521/posts/default/4614186831325267755'/><link rel='alternate' type='text/html' href='http://newcsharp.blogspot.com/2008/02/create-3d-directx-animation-in-c-and.html' title='Create 3D DirectX Animation in C# and .NET'/><author><name>.NET team</name><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-2557049885090666521.post-6409627274176644051</id><published>2008-01-31T17:32:00.000+05:30</published><updated>2008-01-31T18:51:10.890+05:30</updated><title type='text'>asp.net Certification Faqs</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: verdana;"&gt;Query1 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;====== &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;A project on which you are working calls for you&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: ve
