I'm having a trouble with the '
character in a connection string. Entity Framework throws an exception saying:
Format of the initialization string does not conform to specification starting at index
I tried the answers suggested here and here to no avail.
I also tried constructing it with SqlConnectionStringBuilder
class and got the same exception as a result.
Can anyone help me out?
Thanks in advance.
EDIT:
The connectionstring is indeed in the web.config file and it looks like this:
<add name="TestEntities" connectionString="metadata=res://*/DAL.TestModel.csdl|res://*/DAL.TestModel.ssdl|res://*/DAL.TestModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\testsource;initial catalog=testdb;User Id=testuser;Password=test'password;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
the problem is with the Password=test'password
bit.
- I can't put it in double quotes because it's already surrounded by them.
- I can't put it between
"
-s because it's already surrounded by them too. - And I can't put it in single quotes because the single quote itself is what I'm trying to escape.
Password='test'password'
doesn't work.