Click here to Skip to main content
15,884,537 members
Articles / Programming Languages / XSLT

Custom Configuration SQL Connection String Section

Rate me:
Please Sign up or sign in to vote.
3.42/5 (7 votes)
23 Jan 2006CPOL5 min read 90.2K   1K   24  
This solution demonstrates enforcing valid SQL connection strings in the App.Config file.
<?xml version="1.0" encoding="UTF-8"?>
<!--
	Example of a SqlConnectionStringConnection.Xml file
-->
<SqlConnectionStringCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SqlConnectionStringCollection.xsd">
	<SqlConnectionString ID="App.Trusted" Required="true">
		<Authentication Persist="false">
			<Trusted/>
		</Authentication>
		<Database>
			<Name>MYDATABASE</Name>
		</Database>
	</SqlConnectionString>
	<SqlConnectionString ID="App.Web" Required="true">
		<Authentication Persist="false">
			<Trusted/>
		</Authentication>
		<Database>
			<Name>MYDATABASE</Name>
		</Database>
		<Server Port="2433">
			<Name>MYSERVER</Name>
		</Server>
	</SqlConnectionString>
	<SqlConnectionString ID="Log" Required="false">
		<Authentication Persist="false">
			<LogIn>
				<UserID>MYLOGIN</UserID>
			</LogIn>
		</Authentication>
		<ConnectionPooling Lifetime="0" Reset="true" Enlist="true" MaxSize="100" MinSize="0" Pooling="true"/>
		<Connectivity NetworkLibrary="dbmssocn" Timeout="15" Encrypt="false" PacketSize="8192"/>
		<CurrentLanguage>us_english</CurrentLanguage>
		<Database>
			<Name>MYDATABASE</Name>
			<File>c:\FileName</File>
		</Database>
		<Identification ApplicationName="MYAPPLICATION" WorkstationID="MYWORKSTATION"/>
		<Server Port="1433">
			<IP>192.168.1.1</IP>
		</Server>
	</SqlConnectionString>
	<SqlConnectionString ID="Backup">
		<Authentication Persist="true">
			<LogIn>
				<UserID>MYLOGIN</UserID>
				<Password>MYPASSWORD</Password>
			</LogIn>
		</Authentication>
		<ConnectionPooling Lifetime="0" Reset="true" Enlist="true" MaxSize="99" MinSize="0" Pooling="true"/>
		<Connectivity NetworkLibrary="dbmsgnet" Timeout="15" Encrypt="true" PacketSize="4096"/>
		<Database>
			<Name>MYDATABASE</Name>
			<File>c:\FileName</File>
		</Database>
		<Server Port="2433">
			<IP>192.168.1.1</IP>
		</Server>
	</SqlConnectionString>
</SqlConnectionStringCollection>

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.

License

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


Written By
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

Comments and Discussions