2006-11-09

无法识别的转义序列 的解决方法

private static string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\aspnet\test\data\csndfdata.mdb\;";  
出现错误提示:"无法识别的转义序列".原因主要是:发生该错误的原因通常是在文件名中使用了反斜杠字符,例如:
string filename = "c:\myFolder\myFile.txt";

若要纠正该错误,请使用"\\"或前面带有 @ 且用引号括起的字符串.例如上面的应更改如下 :
private static string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+@"C:\Inetpub\wwwroot\aspnet\test\data\csndfdata.mdb\;";
--
I'm a stone, romantic.stone    blog: http://cscom.bokee.com    http://freetree.bak.cn

没有评论:

发表评论