我正在将以下连接字符串写入web.config,但它给出的error.what是正确的编写方式吗?
<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"/>发布于 2011-01-19 20:05:35
web.config是XML,因此需要将内部引号转义为"
<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"/>发布于 2011-01-19 20:01:30
在字符串内部,用\"替换"以正确地对其进行转义。
这意味着您的字符串应该如下所示:
"<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\"/>"发布于 2011-01-19 20:05:17
它不应该是这样的:
<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"/>https://stackoverflow.com/questions/4734955
复制相似问题