public Bestelling GetBestelling(string code) { this.ResetErrorMessage(); Bestelling bestelling = new Bestelling(""); List <BesteldArtikel> besteldArtikels = GetAllBesteldArtikels(GetBestelnr(code)); try { this.MySqlConnection.Open(); string sql = $"SELECT bestelnr, datum, gebruikersnaam, prijs, code FROM tblbestelling WHERE code = @code;"; MySqlCommand command = new MySqlCommand(sql, this.MySqlConnection); command.Parameters.AddWithValue("@code", code); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { bestelling.BestelNr = reader.GetInt32(0); bestelling.AanmaakDatum = reader.GetDateTime(1); bestelling.GebruikersNaam = reader.GetString(2); bestelling.TotaalBedrag = reader.GetDouble(3); bestelling.Code = reader.GetString(4); } foreach (BesteldArtikel besteldArtikel in besteldArtikels) { bestelling.AddArtikel(besteldArtikel); } //Reader sluiten reader.Close(); } catch (MySqlException ex) { //Bij een error word de ToString van die error op ErrorMessage gezet zodat dit gebruikt kan worden, voornamelijk tijdens het developen this.ErrorMessage = ex.ToString(); } //Connectie sluiten this.MySqlConnection.Close(); //Return object return(bestelling); }