Escape & in App.config
I have the following piece of config in my App.config file:
<add key="ConnectionString"
value="INITIAL CATALOG=myDatabase;DATA SOURCE=myServer;User ID=myUser;Password=!&myPass99;"/>
The above connection string is rejected by Visual Studio intellisense. It says entity myPass99
not defined. The problem is caused by the & in the password.
How do I escape it?
Solution 1:
Escape the ampersand by using &
in place of the &
As an FYI, see here for further characters: What characters do I need to escape in XML documents?