Dolen

导航

.Net Webconfig连接字符串中数据库实例名带'\'的问题

获取前:

获取后:

导致sa登录失败的问题

string strCon = "workstation id=localhost;packet size=4096;user id=" + user + ";data source=" + dbserver + ";persist security info=True;password=";

//判断数据库实例名中是否包含字符串'\',如果包含'\'的话,替换'\\'为'\'

if (strCon.Contains(@"\"))
                                            {
                                                _node.Item(i).Attributes.GetNamedItem("value").InnerText = strCon.Replace(@"\\",@"\");
                                            }
                                            else
                                            {
                                                _node.Item(i).Attributes.GetNamedItem("value").InnerText = strCon;
                                            }

posted on 2016-05-11 14:24  Dolen  阅读(485)  评论(0编辑  收藏  举报