public void EditStudyField(StudyField studyField) { string query = "UPDATE UCL_StudyField SET Name = @Name WHERE Id = @id;"; string param1 = "@id"; string param2 = "@Name"; _db.ExecuteCmd(query, _db.SetParameterWithValue(param1, studyField.Id), _db.SetParameterWithValue(param2, studyField.FieldName)); }
private List <StudyField> ExecuteReaderStudyFields(string query) { _db.Get_Connection(); List <StudyField> list = new List <StudyField>(); using (cmd.Connection = _db.conn) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; try { using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { StudyField sf = new StudyField(); sf.Id = Convert.ToInt32(reader.GetInt32(0)); sf.FieldName = reader.GetString(1).ToString(); sf.Created = reader.GetDateTime(2); sf.Edited = reader.GetDateTime(3); list.Add(sf); } } } catch (Exception) { throw; } finally { if (_db.conn.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } } return(list); }
public void EditStudyField(StudyField studyField) { _db = new StudyFieldDB(); _db.EditStudyField(studyField); }