public BoatDO ViewBoatByID(Int64 BoatID) { BoatDO boat = new BoatDO(); SqlConnection connection = null; SqlDataAdapter adapter = null; DataTable table = new DataTable(); SqlCommand command = null; try { connection = new SqlConnection(_ConnectionString); command = new SqlCommand("VIEW_BOAT_BY_ID", connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.AddWithValue("@BoatID", BoatID); adapter = new SqlDataAdapter(command); adapter.Fill(table); boat = BoatMap2.DataTableToList(table).FirstOrDefault(); } catch (Exception ex) { logger.Log("Fatal", ex.Source, ex.TargetSite.ToString(), ex.Message, ex.StackTrace); throw ex; } finally { if (connection != null) { connection.Close(); connection.Dispose(); } } return(boat); }
public List <BoatDO> ViewSailboats() { List <BoatDO> allSailboats = new List <BoatDO>(); SqlConnection connection = null; SqlDataAdapter adapter = null; DataTable table = new DataTable(); SqlCommand command = null; try { connection = new SqlConnection(_ConnectionString); command = new SqlCommand("VIEW_SAILBOATS", connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); adapter = new SqlDataAdapter(command); adapter.Fill(table); allSailboats = BoatMap2.DataTableToList(table); } catch (Exception ex) { logger.Log("Fatal", ex.Source, ex.TargetSite.ToString(), ex.Message, ex.StackTrace); throw ex; } finally { if (connection != null) { connection.Close(); connection.Dispose(); } if (adapter != null) { adapter.Dispose(); } } return(allSailboats); }