public static List <VideoCategory> GetAll() { DBCon con = new DBCon(); SqlCommand cmd = null; SqlDataReader SDR = null; List <VideoCategory> listvideo = new List <VideoCategory>(); try { string Query = "Select *From VideoCategory ORDER BY Id DESC"; cmd = new SqlCommand(Query, con.Con); SDR = cmd.ExecuteReader(); while (SDR.Read()) { VideoCategory ObjTmp = new VideoCategory(); ObjTmp.Id = SDR.GetInt32(0); ObjTmp.Name = SDR.GetString(1); ObjTmp.OrderNo = SDR.GetInt32(2); listvideo.Add(ObjTmp); } } catch (System.Exception e) { e.ToString(); } finally { cmd.Dispose();; con.Con.Close(); } return(listvideo); }
public static VideoCategory GetOne(int Id) { DBCon con = new DBCon(); SqlCommand cmd = null; SqlDataReader SDR = null; VideoCategory ObjTmp = new VideoCategory(); try { string Query = "SELECT * FROM VideoCategory where ID=" + Id; cmd = new SqlCommand(Query, con.Con); cmd.Parameters.AddWithValue("@ID", Id); SDR = cmd.ExecuteReader(); while (SDR.Read()) { ObjTmp.Id = SDR.GetInt32(0); ObjTmp.Name = SDR.GetString(1); ObjTmp.OrderNo = SDR.GetInt32(2); } } catch (System.Exception e) { e.ToString(); } finally { cmd.Dispose();; con.Con.Close(); } return(ObjTmp); }