Example #1
0
        public SongCollection GetSong(int songID)
        {
            SongCollection song = new SongCollection();

            using (_connection)
            {
                SqlCommand cmd = new SqlCommand("spGetSong", _connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@SongID", songID);
                _connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    song.SongID   = songID;
                    song.Title    = reader.GetString(0);
                    song.ArtistID = reader.GetInt32(1);
                    song.Price    = reader.GetInt32(2);
                }
            }
            return(song);
        }
Example #2
0
        public List <SongCollection> GetAllSongs()
        {
            List <SongCollection> allSongs = new List <SongCollection>();

            using (_connection)
            {
                SqlCommand cmd = new SqlCommand("spGetAllSongs", _connection);
                cmd.CommandType = CommandType.StoredProcedure;
                _connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    SongCollection song = new SongCollection();
                    song.SongID   = reader.GetInt32(0);
                    song.Title    = reader.GetString(1);
                    song.ArtistID = reader.GetInt32(2);
                    song.Price    = reader.GetInt32(3);
                    allSongs.Add(song);
                }
            }
            return(allSongs);
        }
Example #3
0
        public List <SongCollection> SearchByPerformer(int artistID, string zoekterm = "")
        {
            List <SongCollection> songs = new List <SongCollection>();

            using (_connection)
            {
                SqlCommand cmd = new SqlCommand("spSearchByPerformer", _connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ArtistID", artistID);
                cmd.Parameters.AddWithValue("@Zoekterm", zoekterm);
                _connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    SongCollection song = new SongCollection();
                    song.SongID   = reader.GetInt32(0);
                    song.Title    = reader.GetString(1);
                    song.ArtistID = reader.GetInt32(2);
                    song.Price    = reader.GetInt32(3);
                    songs.Add(song);
                }
            }
            return(songs);
        }