簡體   English   中英

雙引號內的雙引號

[英]double quotes inside double quotes

我正在將以下連接字符串寫入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"/>

web.config是XML,因此您需要將內部引號轉義為&quot;

<add name="stargaze_stargazeConnectionString1" 
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;D:\Work At DS\19th Jan\myastrolove.com_new\App_Data\dbName.mdf&quot;;Integrated Security=True;User Instance=True"/>

在字符串內部,替換" with \\"以正確地逃避它。

這意味着你的字符串應如下所示:

"<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\"/>"

不應該是這樣的:

<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"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM