public void PopulateGlossaryMolecules() { buttonListControl.RefreshButtons(); string connectionPath = "URI=file:" + Application.dataPath + "/Elementrium.db"; IDbConnection dbconn; dbconn = (IDbConnection) new SqliteConnection(connectionPath); dbconn.Open(); IDbCommand dbcmd = dbconn.CreateCommand(); //string sqlQuery = "SELECT Trium.ID, Trium.Name, Trium.ElementID, Element.AtomicNumber, Trium.Formula, " + //"Trium.Mass, Trium.FactOne, Trium.FactTwo, Trium.FactThree FROM Trium" //+ "INNER JOIN Element ON Trium.ElementID=Element.ID"; string sqlQuery = "SELECT Trium.ID, Trium.Name, Trium.Formula, Trium.Mass, IFNULL(Trium.FactOne, 'X'), IFNULL(Trium.FactTwo, 'X'), IFNULL(Trium.FactThree, 'X'), IFNULL(Molecule.CommonName, 'X') " + "FROM Trium INNER JOIN Molecule on Molecule.ID = IFNULL(Trium.MoleculeID, -1) WHERE Trium.ID > 92 ORDER BY Trium.Name ASC"; dbcmd.CommandText = sqlQuery; IDataReader reader = dbcmd.ExecuteReader(); // reader.Read() will return True or False. If true, we will execute what is in the while() loop while (reader.Read()) { int id = reader.GetInt32(0); /* the ID column of the Trium */ string molecule = reader.GetString(1); /* the Name column of the Trium */ string formula = reader.GetString(2); /* the Formula column of the Trium */ decimal mass = reader.GetDecimal(3); string commonname = reader.GetString(7); if (commonname == "X") { commonname = ""; } string first = reader.GetString(4); if (first == "X") { first = ""; } string second = reader.GetString(5); if (second == "X") { second = ""; } string third = reader.GetString(6); if (third == "X") { third = ""; } if ((id) < GlossaryUIDispenser.sprites.Count) { if (GlossaryUIDispenser.sprites[id] != null) { Sprite spr = GlossaryUIDispenser.sprites[id]; if (bp.getTrium(id) != null) { buttonListControl.PopulateSecondList(molecule, commonname, mass, formula, first, second, third, spr, id); } } } /*this.names.text = element.ToString(); * this.info.text = "Atomic Number: " +id;*/ } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; }