Beispiel #1
0
        /// <summary>
        /// Fetches all the agencies in the table.
        /// </summary>
        /// <returns>Returns a list of agencies.</returns>
        public static List<AgencyItem> FetchDataAgencies()
        {
            try
            {
                List<AgencyItem> list = new List<AgencyItem>();
                string sql = "SELECT DISTINCT Agency FROM Bid";

                SetConnectionString();
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = new SqlCommand(sql, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                do
                                {
                                    //sets the value from the reader
                                    AgencyItem item = new AgencyItem();
                                    item.Value = (string)reader["Agency"];
                                    list.Add(item);
                                    item = null;
                                } while (reader.Read());
                            }
                        }
                    }
                }

                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fetches all the agencies in the table.
        /// </summary>
        /// <returns>Returns a list of agencies.</returns>
        public static List <AgencyItem> FetchDataAgencies()
        {
            try
            {
                List <AgencyItem> list = new List <AgencyItem>();
                string            sql  = "SELECT DISTINCT Agency FROM Bid";

                SetConnectionString();
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = new SqlCommand(sql, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                do
                                {
                                    //sets the value from the reader
                                    AgencyItem item = new AgencyItem();
                                    item.Value = (string)reader["Agency"];
                                    list.Add(item);
                                    item = null;
                                } while (reader.Read());
                            }
                        }
                    }
                }

                return(list);
            }
            catch (Exception)
            {
                throw;
            }
        }