Web.config and quotes in connectionStrings

I have the following connection string and you will notice “Provider tests”, pay attention to one quote, how can I enter it into the web.config file to make it valid?

<connectionStrings>
    <clear/>
    <add name="Provider" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Projects\Provider's.Tests\app_data\db.mdf";Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
+5
source share
4 answers

I do not think this is a problem Provider's, these are double quotes around the path.
Try just deleting it so it saysAttachDbFilename=C:\Projects\Provider's.Tests\app_data\db.mdf;

If this is important in the connection string, try encoding it: AttachDbFilename=&quot;C:\Projects\Provider's.Tests\app_data\db.mdf;&quot;

+7
source

, . (") &quot;, (') &apos;. - , .

<connectionStrings>
    <clear/>
    <add name="Provider" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\Projects\Provider&apos;s.Tests\app_data\db.mdf&quot;;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
+2

' " , web.config.

, , , .

+1

. . :

<add 
    name="Provider" 
    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\Projects\Provider's.Tests\app_data\db.mdf&quot;;Integrated Security=True;User Instance=True" 
    providerName="System.Data.SqlClient"/>
+1

All Articles