public static rrNews GetNews(int NewsId) { rrNews result = null; using (SqlConnection conn = new SqlConnection(SQL.RifleRange)) { try { SqlCommand cmd = new SqlCommand("dbo.usp_GetNews", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@NewsId", NewsId); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null && !reader.IsClosed) { while (reader.Read()) { result = new rrNews(reader); } reader.Close(); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } } return(result); }
public static LinkedList <rrNews> GetNewsList() { LinkedList <rrNews> result = new LinkedList <rrNews>(); using (SqlConnection conn = new SqlConnection(SQL.RifleRange)) { try { SqlCommand cmd = new SqlCommand("dbo.usp_GetNews", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null && !reader.IsClosed) { result = new LinkedList <rrNews>(); while (reader.Read()) { rrNews obj = new rrNews(reader); result.AddLast(obj); } reader.Close(); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } } return(result); }