Reputation: 4298
i am writing the following connection string into web.config but it giving me error.what is the correct way to write it?
<add name="stargaze_stargazeConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="D:\Work At DS\19th Jan\myastrolove.com_new\App_Data\dbName.mdf";Integrated Security=True;User Instance=True"/>
Upvotes: 4
Views: 5219
Reputation: 499262
web.config is XML, so you need to escape the inner quotes to "
:
<add name="stargaze_stargazeConnectionString1"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename="D:\Work At DS\19th Jan\myastrolove.com_new\App_Data\dbName.mdf";Integrated Security=True;User Instance=True"/>
Upvotes: 14
Reputation: 4908
Shouldn't it be like:
<add name="stargaze_stargazeConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=\"D:\Work At DS\19th Jan\myastrolove.com_new\App_Data\dbName.mdf\";Integrated Security=True;User Instance=True"/>
Upvotes: -1
Reputation: 60724
Inside the string, replace "
with \"
to properly escape it.
That means that your string should look like this:
"<add name=\"stargaze_stargazeConnectionString1\" connectionString=\"Data Source=.\SQLEXPRESS;AttachDbFilename=\"D:\Work At DS\19th Jan\myastrolove.com_new\App_Data\dbName.mdf\";Integrated Security=True;User Instance=True\"/>"
Upvotes: 2