public Trainee find_an_employee(OleDbConnection conn, string fName, string lName) { Trainee emply = new Trainee(); string query = "select * from [TRAINEES] where [FNAME]=? and [LNAME]=?"; using (OleDbCommand cmd = new OleDbCommand(query, conn)) { cmd.Parameters.AddWithValue("?", fName); cmd.Parameters.AddWithValue("?", lName); using (OleDbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { emply.lastName = reader[0].ToString(); emply.firstName = reader[1].ToString(); emply.midInit = reader[2].ToString(); } return(emply); } } }
public List <Trainee> find_employees(OleDbConnection conn) { List <Trainee> empList = new List <Trainee>(); // this isn't getting the whole Trainees table! string query = "select * from [TRAINEES]"; using (OleDbCommand cmd = new OleDbCommand(query, conn)) { using (OleDbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Trainee temp = new Trainee(); temp.lastName = reader[0].ToString(); temp.firstName = reader[1].ToString(); temp.midInit = reader[2].ToString(); empList.Add(temp); } return(empList); } } }