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