public void PopulateGlossaryAtoms() { 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'), Element.AtomicNumber " + "FROM Trium " + "INNER JOIN Element ON Element.ID = IFNULL(Trium.ElementID, -1) " + "WHERE IFNULL(Element.AtomicNumber, -1) <= 92"; 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 element = 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 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 = ""; } int atomicnum = id; if ((atomicnum - 1) < GlossaryUIDispenser.sprites.Count) { if (GlossaryUIDispenser.sprites[atomicnum - 1] != null) { Sprite spr = GlossaryUIDispenser.sprites[atomicnum - 1]; if (bp.getTrium(id) != null) { buttonListControl.PopulateList(element, atomicnum, mass, formula, first, second, third, spr); } } } /*if (bp.getTrium(id) != null) { * buttonListControl.PopulateList (element, atomicnum, mass, formula, first, second, third, spr); * }*/ /*this.names.text = element.ToString(); * this.info.text = "Atomic Number: " +id;*/ } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; }