1
1楼 miaomiaoga 2007-01-16 10:51:07 Modify1( "SqlServer ", "xxxxxxxxxxxxxx "); 出错信息为找不到 <add name= "SqlServer " 这一段,但看上去没错啊。请各位指导一下。:) public void Modify1(string key, string strValue) { string XPath = "/configuration/connectionStrings/add[@name= '? '] "; XmlDocument domWebConfig = new XmlDocument(); domWebConfig.Load((Context.Parameters[ "targetdir "] + "\\web.config ")); XmlNode addKey = domWebConfig.SelectSingleNode((XPath.Replace( "? ", key))); if (addKey == null) { throw new ArgumentException( "没有找到 <add name= ' " + key + " ' connectionString=.../> 的配置节 "); } addKey.Attributes[ "connectionString "].InnerText = strValue; domWebConfig.Save((Context.Parameters[ "targetdir "] + "\\web.config ")); } web.config的文件如下: <?xml version= "1.0 "?> <configuration xmlns= "http://schemas.microsoft.com/.NetConfiguration/v2.0 "> <connectionStrings> <add name= "SqlServer " connectionString= "Database=20061228;Server=Localhost;Integrated Security=SSPI; " providerName= "System.Data.SqlClient " /> </connectionStrings> ..... ..... ......... 2楼 miaomiaoga 2007-01-16 11:48:00 我把 <configuration xmlns= "http://schemas.microsoft.com/.NetConfiguration/v2.0 "> 替?成 <configuration> 就可以了,但那?xmlns= "http://schemas.microsoft.com/.NetConfiguration/v2.0 "是我用Enterprise Library自?生成的啊,不知道去掉有?有什???. 有知道的朋友?? 4楼 facebookdotcom 2008-12-20 17:29:09 Click the link to solve your problem.Good luck!
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||