Click here to Skip to main content
11,935,053 members (49,630 online)
Click here to Skip to main content
Articles » Database » Database » Databases » Downloads


24 bookmarked

Custom Configuration SQL Connection String Section

, 23 Jan 2006 CPOL
This solution demonstrates enforcing valid SQL connection strings in the App.Config file.
<?xml version="1.0" encoding="UTF-8"?>
Fair License

Copyright (c) 2005 Theodore William Bouskill

Usage of the works is permitted provided that this
instrument is retained with the works, so that any entity
that uses the works is notified of this instrument.

<xsl:stylesheet version="1.0" xmlns:xsl="">
	<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="Authentication">
		<xsl:if test="@Persist = 'true'">Persist Security Info=True; </xsl:if>
		<xsl:if test="Trusted">Integrated Security=True; </xsl:if>
		<xsl:apply-templates select="LogIn"/>
	<xsl:template match="Authentication/LogIn">
		<xsl:if test="UserID">User ID=<xsl:value-of select="UserID"/>; </xsl:if>
		<xsl:if test="Password">Password=<xsl:value-of select="Password"/>; </xsl:if>
	<xsl:template match="ConnectionPooling">
		<xsl:if test="@Enlist != 'true'">Enlist=<xsl:value-of select="@Enlist"/>; </xsl:if>
		<xsl:if test="@Lifetime != '0'">Connection Lifetime=<xsl:value-of select="@Lifetime"/>; </xsl:if>
		<xsl:if test="@MinSize != '0'">Min Pool Size=<xsl:value-of select="@MinSize"/>; </xsl:if>
		<xsl:if test="@MaxSize != '100'">Max Pool Size=<xsl:value-of select="@MaxSize"/>; </xsl:if>
		<xsl:if test="@Pooling != 'true'">Pooling=<xsl:value-of select="@Pooling"/>; </xsl:if>
		<xsl:if test="@Reset != 'true'">Connection Reset=<xsl:value-of select="@Reset"/>; </xsl:if>
	<xsl:template match="Connectivity">
		<xsl:if test="@Encrypt != 'false'">Encrypt=<xsl:value-of select="@Encrypt"/>; </xsl:if>
		<xsl:if test="@NetworkLibrary != 'dbmssocn'">Network Library=<xsl:value-of select="@NetworkLibrary"/>; </xsl:if>
		<xsl:if test="@PacketSize != '8192'">Packet Size=<xsl:value-of select="@PacketSize"/>; </xsl:if>
		<xsl:if test="@Timeout">Connection Timeout=<xsl:value-of select="@Timeout"/>; </xsl:if>
	<xsl:template match="Database">
		<xsl:if test="Name">Database=<xsl:value-of select="Name"/>; </xsl:if>
		<xsl:if test="File">AttachDBFilename=<xsl:value-of select="File"/>; </xsl:if>
	<xsl:template match="Identification">
		<xsl:if test="@ApplicationName">Application Name=<xsl:value-of select="@ApplicationName"/>; </xsl:if>
		<xsl:if test="@WorkstationID">Workstation ID=<xsl:value-of select="@WorkstationID"/>; </xsl:if>
	<xsl:template match="Server">
			<xsl:when test="Name">Server=<xsl:value-of select="Name"/></xsl:when>
			<xsl:when test="IP">Network Address=<xsl:value-of select="IP"/></xsl:when>
		<xsl:if test="@Port != '1433'">,<xsl:value-of select="@Port"/></xsl:if>;</xsl:template>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ted Bouskill
Software Developer (Senior)
Canada Canada
Very experienced Senior Software Developer/Manager with natural leadership and proven project management skills.

Started in Civil Engineering leading the integration of PC's into the Engineering process as a Design/Drafting Technician as well as an in-house Software Developer then transitioned into a full time Software Development career in the early 90's.

Ability to change and adapt has led to diverse experience with a wide array of technology and roles from graphics or web development to designing line of business enterprise applications.

Knowledge Base: Sharepoint, C#, SQL, ASP.NET, C++, CSS, HTML, JavaScript, XML, XSLT

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 24 Jan 2006
Article Copyright 2006 by Ted Bouskill
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid