我正在尝试使用C#调用存储过程。
在以下代码行中,我遇到了问题。
SqlConnection("Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
我无法使用的部分是服务器
DB2\XPT
。我需要怎么做才能使用服务器名称为
DB2\XPT
?我正在尝试使用C#调用存储过程。
在以下代码行中,我遇到了问题。
SqlConnection("Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
DB2\XPT
。DB2\XPT
?("Server=DB2\\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
或者(@"Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI")
如果你想要在连接字符串中避免转义字符,你需要转义反斜杠 \
或使用 @
符号。
SqlConnection(@"Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
SqlConnection("Server=DB2\\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");