日期:2014-05-20  浏览次数:20904 次

未将对想引用设置到对象的实例 郁闷死了
private static SqlConnection con;
        public static SqlConnection Con
        {
            get 
            {
                string conString = ConfigurationManager.ConnectionStrings["HR"].ConnectionString;
                if (con == null)
                {
                    con = new SqlConnection(conString);
                    con.Open();
                }
                else if (con.State == System.Data.ConnectionState.Closed)
                {
                    con.Open();
                }
                else if (con.State == System.Data.ConnectionState.Broken)
                {
                    con.Close();
                    con.Open();
                }
                return con;
            }
        }


哪个地方出错了啊。好纠结
------解决方案--------------------
string conString = ConfigurationManager.ConnectionStrings["DBConnctionString"].ConnectionString;


请确保连接字符串是否获取正确,断点调试一下.