让LinqToSQL使用Web.Config中的链接字符串(修改Settings.Designer.cs)

 [global::System.Configuration.ApplicationScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
        [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=MatchDB;Persist Security Info=True;Us" +
            "er ID=sa;Password=sa")]
        public string  MatchDBConnectionString {
            get {
                    //下面这几句
                var connstr = "MatchDBConnectionString";//web.config里的conn名
                return System.Configuration.ConfigurationManager.ConnectionStrings[connstr].ConnectionString ??
                    ((string)(this["MatchDBConnectionString"]));
            }
        }

 

转载于:https://www.cnblogs.com/hsw-2013/p/4255276.html

你可能感兴趣的:(让LinqToSQL使用Web.Config中的链接字符串(修改Settings.Designer.cs))