连接字符串中无法识别的转义序列 [英] Unrecognized escape sequence in connection string

查看:1786
本文介绍了连接字符串中无法识别的转义序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



$ b

  NEPOLEON \ADMN在这里。 NEPOLEON \ADMN是我的SQL服务器名称。 

SqlConnection con = new SqlConnection(Server = NEPOLEON\ADMN; Database = MASTER; Trusted_Connectopn = True);


解决方案

转义\字符like:

  SqlConnection con = new SqlConnection(Server = NEPOLEON\\ADMN; Database = MASTER; Trusted_Connectopn = True); 

  SqlConnection con = new SqlConnection(@Server = NEPOLEON\ADMN; Database = MASTER; Trusted_Connectopn = True); 


when ever I make connection it gives an error

Unrecognized escape sequence.

NEPOLEON\ADMN HERE ON THIS SLASH. NEPOLEON\ADMN IS MY SQL SERVER NAME.

SqlConnection con = new SqlConnection("Server=NEPOLEON\ADMN;Database=MASTER;Trusted_Connectopn=True");

解决方案

Escape the \ character like :

SqlConnection con = new SqlConnection("Server=NEPOLEON\\ADMN;Database=MASTER;Trusted_Connectopn=True");

or

SqlConnection con = new SqlConnection(@"Server=NEPOLEON\ADMN;Database=MASTER;Trusted_Connectopn=True");

这篇关于连接字符串中无法识别的转义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆