vs2005 C#数据库字符串问题,在线等待.
我用vs2005 C#连接SQL数据库文件,
SqlConnection con = new SqlConnection( "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ASP2005\votecontrol\vote.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True ");
但是提示无法识别的转义序列,问题出在Data Source=.\SQLEXPRESS中的"\".请问题如何解决?谢谢.
[解决办法]
SqlConnection con = new SqlConnection(@ "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ASP2005\votecontrol\vote.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True ");
[解决办法]
要么前面加转义字符 "@ ":
SqlConnection con = new SqlConnection(@ "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ASP2005\votecontrol\vote.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True ");
要么将 "\ "替换成 "/ "
SqlConnection con = new SqlConnection( "Data Source=./SQLEXPRESS;AttachDbFilename=D:/ASP2005/votecontrol/vote.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True ");