예제 #1
0
        public List <Banks> GetSemua()
        {
            List <Banks> list = new List <Banks>();

            var conn = new  SqlConnection(constr);

            conn.Open();
            string        query  = "Select*from Banks";
            SqlCommand    cmd    = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();

            Banks b = null;

            while (reader.Read())
            {
                b = new Banks(reader);
                list.Add(b);
            }
            conn.Close();
            return(list);
        }
예제 #2
0
        public List <Banks> getByAccountID(int aid)
        {
            List <Banks> list = new List <Banks>();

            using (var conn = new SqlConnection(constr))
            {
                conn.Open();
                string     query = "SELECT * FROM BANKS where AccountID=@0";
                SqlCommand cmd   = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@0", aid);
                SqlDataReader reader = cmd.ExecuteReader();
                Banks         b      = null;

                while (reader.Read())
                {
                    b = new Banks(reader);
                    list.Add(b);
                }
                conn.Close();
            }
            return(list);
        }