日期:2014-05-17  浏览次数:21006 次

求大神看看一段代码,急!!!!!!!!!
 #region 根据登陆的user_Id 获取用户信息
        public static Ksd_User_Info GetUserByUserId(string userid)
        {
            try
            {
                Ksd_User_Info userinfo = null;
                string sql = "proc_ckq_GetUserinfobyUerId";
                string Connstring2 = ConfigurationManager.ConnectionStrings["Conn_public"].ConnectionString;
                SqlConnection con = new SqlConnection(Connstring2);
                con.Open();
                SqlCommand command = new SqlCommand(sql,con);
                command.CommandType = CommandType.StoredProcedure;
                SqlParameter[] para = new SqlParameter[]{
                               new SqlParameter("@user_id",userid) };
                command.Parameters.AddRange(para);
                SqlDataReader dr = command.ExecuteReader();
                if (!dr.IsDBNull(0))
                {
                    if (dr.Read())
                    {
                        userinfo = new Ksd_User_Info();
                        if (!(dr["User_Id"] is DBNull))
                            userinfo.User_Id = Convert.ToString(dr["User_Id"]);
                        if (!(dr["User_Pwd"] is DBNull))
                            userinfo.User_Pwd = Convert.ToString(dr["User_Pwd"]);
                        if (!(dr["Us