예제 #1
0
        /// <summary>
        /// Get an entry from the ZipCodeState table
        /// </summary>
        public static ZipCodeState Get(int id)
        {
            ZipCodeState result = null;

            SqlConnection cn = GetConnection();

            result = Get(cn, id);
            FinishedWithConnection(cn);

            return(result);
        }
예제 #2
0
        private static ZipCodeState Get(SqlConnection cn, int id)
        {
            ZipCodeState result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM ZipCodeState WHERE ZipCodeStateId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildZipCodeState(rdr);
                    }
                }
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Get an entry from the ZipCodeState table
        /// </summary>
        public static ZipCodeState GetByName(string name)
        {
            ZipCodeState  result = null;
            SqlConnection cn     = GetConnection();

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM ZipCodeState WHERE ZipCodeStateAbbreviation LIKE @ZipCodeStateAbbreviation OR ZipCodeStateName LIKE @ZipCodeStateName", cn))
            {
                BuildSqlParameter(cmd, "@ZipCodeStateAbbreviation", SqlDbType.Text, name);
                BuildSqlParameter(cmd, "@ZipCodeStateName", SqlDbType.Text, name);
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildZipCodeState(rdr);
                    }
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }