Using Special Characters in Web.Config Connection String

For characters that are reserved in HTML and XML you can use the entity name (or entity number) for the character.

Such as:

< is really &lt; (or <)

> is really &gt; (or >)

& is really &amp; (or &)

” is really &quot; (or ")

So for a password:

my&password

the connection string will be

<add name=”artepn” connectionString=”Data Source=MyServer;Initial Catalog=MyTable;Persist Security Info=True;User ID=MyUser;Password=my&amp;password” providerName=”System.Data.SqlClient” />

or

<add name=”artepn” connectionString=”Data Source=MyServer;Initial Catalog=MyTable;Persist Security Info=True;User ID=MyUser;Password=my&password” providerName=”System.Data.SqlClient” />

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s