首页 > 代码库 > 使用SqlDataReader获取只读数据

使用SqlDataReader获取只读数据

 public static SqlDataReader GetUserLogin(string ssss)
       {
           sql = "select UserPerson,UserAge,UsercRreateTime from T_User where UserName=@userName ";        
           con = ConSQL();
           cmd = new SqlCommand(sql, con);
           try
           {
               con.Open();
               SqlParameter ps = new SqlParameter("@userName ", ssss);
               cmd.Parameters.Add(ps);
               return cmd.ExecuteReader(CommandBehavior.CloseConnection);
           }
           catch (Exception e)
           {
               throw new Exception("执行任务失败:" + e.Message + " " + sql);
           }     
       }

使用SqlDataReader获取只读数据