public void LoadGevolgdeOpleidingen(SqliteConnection conn, string id) { bool shouldClose = false; // clear last connection to preventcirculair call to update _conn = null; // Is the database already open? if (conn.State != ConnectionState.Open) { shouldClose = true; conn.Open(); } using (var commandGO = conn.CreateCommand()) { try { // Create new command commandGO.CommandText = "SELECT DISTINCT ID FROM [GevolgdeOpleiding] WHERE PersoonID = '" + ID + "'"; using (var readerGO = commandGO.ExecuteReader()) { while (readerGO.Read()) { var gevopl = new GevolgdeOpleidingModel(); var idGO = (string)readerGO["ID"]; gevopl.Load(conn, idGO); GevolgdeOpleidingen.Add(gevopl); } } } catch (Exception Exception) { Debug.WriteLine(Exception.Message); } } if (shouldClose) { conn.Close(); } // Save last connection _conn = conn; }
void LoadGevolgdeOpleidingen(SqliteConnection conn, string PersoonID) { GevolgdeOpleidingen.Clear(); bool shouldClose = false; // Is the database already open? if (conn.State != ConnectionState.Open) { shouldClose = true; conn.Open(); } // Execute query using (var command = conn.CreateCommand()) { try { // Create new command command.CommandText = "SELECT DISTINCT ID FROM [GevolgdeOpleiding] WHERE PersoonID = '" + PersoonID + "'"; using (var reader = command.ExecuteReader()) { while (reader.Read()) { var gevolgdeopleiding = new GevolgdeOpleidingModel(); var id = (string)reader["ID"]; gevolgdeopleiding.Load(conn, id); GevolgdeOpleidingen.Add(gevolgdeopleiding); } } } catch (Exception Exception) { Debug.WriteLine(Exception.Message); } } if (shouldClose) { conn.Close(); } }