public void LoadByWord(ICollection <wordsObject> collection, string word) { string sql = "select * from words where word=@word"; using (MySqlConnection conn = new MySqlConnection(constr)) { try { conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) using (MySqlDataReader row = cmd.ExecuteReader()) { cmd.Parameters.AddWithValue("@word", word); while (row.Read()) { wordsObject w = new wordsObject(row); collection.Add(w); } } } catch (MySqlException e) { throw; } } }
public void Load(ICollection <wordsObject> collection) { string sql = "select * from words "; using (MySqlConnection conn = new MySqlConnection(constr)) { try { conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) using (MySqlDataReader row = cmd.ExecuteReader()) { while (row.Read()) { wordsObject w = new wordsObject(row); collection.Add(w); } } } catch (MySqlException e) { throw; } } }