public List <OtherFee> GetById() { try { //prepare connection string using (MySqlConnection con = new MySqlConnection(GOCSystem2018.Config.GetConnectionString())) { //try to open connection con.Open(); //prepare sql query string sql = "SELECT * FROM other_fee WHERE id =@id;"; MySqlCommand cmd = new MySqlCommand(sql, con); cmd.Parameters.AddWithValue("id", id); MySqlDataReader reader = cmd.ExecuteReader(); //loop while have record while (reader.Read()) { //instantiate model OtherFee otherFee = new OtherFee(); //prepare properties otherFee.id = Convert.ToInt32(reader["id"].ToString()); otherFee.otherFeeName = reader["other_fee_name"].ToString(); otherFee.otherFeeAmount = Convert.ToDouble(reader["other_fee_amount"]); otherFee.strand = reader["strand"].ToString(); otherFees.Add(otherFee); } } } catch (MySqlException ex) { MessageBox.Show("ERROR : " + ex.ToString(), "GOCINFOSYS", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(otherFees); }