public void PopulatePlaylists() { playlist_list.Clear(); SqlDataReader SAIDA; SqlDataAdapter da2 = new SqlDataAdapter(); if (cn.State == ConnectionState.Closed) { cn.Open(); } SqlCommand command = new SqlCommand("SELECT * FROM SampleKeeper.getPlaylists(@User_ID)", cn); command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@User_ID", userid); SAIDA = command.ExecuteReader(); if (SAIDA.HasRows) { while (SAIDA.Read()) { playlist_list.Add(new Playlist(SAIDA.GetInt32(0), SAIDA.GetString(1))); } } SAIDA.Close(); List <string> newlist = new List <string>(); for (int i = 0; i < playlist_list.Count; i++) { newlist.Add(playlist_list[i].nome); } PlaylistBox.ItemsSource = newlist; }
public void PopulateAlbums() { j = 0; i = 1; k = 2; album_list.Clear(); SqlDataReader SAIDA; SqlDataAdapter da2 = new SqlDataAdapter(); if (cn.State == ConnectionState.Closed) { cn.Open(); } SqlCommand command = new SqlCommand("SELECT * FROM SampleKeeper.populate_albums()", cn); command.CommandType = CommandType.Text; SAIDA = command.ExecuteReader(); if (SAIDA.HasRows) { while (SAIDA.Read()) { album_list.Add(new Album(SAIDA.GetString(0), SAIDA.GetString(1), SAIDA.GetInt32(2), SAIDA.GetString(3), SAIDA.GetString(4), SAIDA.GetString(5))); } } SAIDA.Close(); }