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