A quick and easy utility method which could be used for formatting an XML input string.

/// <summary>
/// Formats and returns the input Xml string.
/// </summary>
/// <param name="xmlString"></param>
public static string FormatXml( string xmlString )
    if ( !String.IsNullOrEmpty( xmlString ) )
        XmlTextReader xmlRdr = new XmlTextReader( new
                                       StringReader( xmlString ) );

        StringWriter textWriter = new StringWriter();

        XmlTextWriter xmlWriter = new XmlTextWriter( textWriter );

        xmlWriter.Formatting = Formatting.Indented;

        xmlWriter.WriteNode( xmlRdr, false );
        return textWriter.ToString();
        return string.Empty;

Our team ran into a problem recently in ASP.NET. We’re using a web service in our web application for data access. The web reference was added to a class library project in our Visual Studio 2005 solution. (We use the WAP – Web Application Project – model) . Simply right clicking on the project name in solution explorer and choose ‘Add web reference’ from the context menu. Everything was working perfectly fine.

The problems started when we tried deploying the application to a test server prior to going live with it. The web service was no longer being referenced properly. We racked our brains for a couple of hours trying to find a solution for this. We had a close look at the class library in which the web service was being referenced and found that the web service path was being saved as a setting in a .config file named app.config. The app.config contained the following XML mark-up:

<configuration xmlns="http://schemas.microsoft.com/.Net Configuration/v2.0">
   <sectiongroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <section name="ACME.Services.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirepermission="false">
     <setting name="ACME_Services_ACMEWebService_ACMEWebService" serializeas="String">

The web reference URL was being read from this config file. But since it was in a class library, the whole thing was getting complied into a DLL on deployment.

The workaround we found for this was:

1. copy the section handler ( the mark-up inside <sectiongroup>…</sectiongroup> ) into the node in the applications Web.config

2. copy the <applicationsettings>…<applicationsettings> section also into the Web.config.

And Voila! Now since this is part of the web.config, it won’t be compiled any more. On deployment, just change the web service path setting ( inside <value>…<value> ) to the new path. Cool, right? 😉

Common Table Expressions is a newly introduced feature in SQL Server 2005. It is similar to a temp table or a view, but its scope is limited to a single SELECT statement.

A CTE is made up of

1. CTE name

2. An optional column list

3. A query defining the CTE

The basic syntax structure for a CTE is:

WITH CTE_name [ ( column_name [,…n] ) ]

The statement to use the CTE is:


Note: The query using the CTE must be the first query appearing after the CTE.


WITH PriceList_CTE( ProductName, ListPrice, DiscountPrice) AS
SELECT [Name] AS ProductName, ListPrice, ListPrice * .95
FROM Production.Product

SELECT ProductName, ListPrice, DiscountPrice
FROM PriceList_CTE

Recursive CTEs

Used for easily traversing heirarchical data structures. Eg: Displaying employees in an organizational chart.

A recursive CTE consists of three elements:

1. Initial sub-query

The seed value.

2. Recursive sub-query

The recursive portion contains a reference to the rows added during the previous iteration.

3. Termination check

Recursion stops automatically whenever an iteration generates no new rows. The final resultset is the union of all result sets generated by the anchor and recursive members.


WITH CTE_name ( column_name [,...n] )
CTE_query_definition –- Anchor member


CTE_query_definition –- Recursive member


Twitter @INullable

  • RT @addyosmani: Our #io19 talk "Speed at Scale" is on YouTube! Lessons from Twitter, eBay, Netflix, Google & more on: ☑️ Perf Budgeting ☑️… 1 day ago
  • RT @teamredblack: Since we founded RedBlack, we have grown to more than 150 clients managing more than $500 billion AUM; with the RIA marke… 1 week ago
  • RT @venkat_s: It was great being part of the 12th edition of GIDS #gids19 A wonderful conference, well organized, fantastic speakers, and… 2 weeks ago
  • RT @shanselman: Quick 9 question one page survey. This will DIRECTLY affect Windows and how developers use it. Remember that “Developer Mod… 2 weeks ago
  • Chat message from teammate - "Assigned pull request to you for review. CI build for pull request has failed. Will p… twitter.com/i/web/status/1… 2 weeks ago

RSS Dot Net Kicks

  • An error has occurred; the feed is probably down. Try again later.