public void Load() { var command = DataStore.Connection.CreateCommand(); SqlCeDataReader reader = null; command.CommandText = "SELECT * FROM [reminders] ORDER BY [time]"; reader = command.ExecuteReader(); while (reader.Read()) { Reminder rem = new Reminder(this); rem.Name = reader.GetString("name"); rem.Text = reader.GetString("text"); rem.Time = reader.GetDateTime("time"); rem.Frequency = reader.GetEnum <Frequency>("frequency"); reminders.Add(rem); rem.Init(); } reader.Dispose(); command.Dispose(); }
public void Add(string name, string text, DateTime time, Frequency freq) { var command = DataStore.Connection.CreateCommand(); var reminder = new Reminder(this) { Name = name, Text = text, Time = time, Frequency = freq }; command.CommandText = "INSERT INTO [reminders] ([name], [text], [time], [frequency]) VALUES (?, ?, ?, ?)"; command.Parameters.AddWithValue("name", name); command.Parameters.AddWithValue("text", text ?? ""); command.Parameters.AddWithValue("time", time); command.Parameters.AddWithValue("freq", freq.ToString()); command.ExecuteNonQuery(); command.Dispose(); reminders.Add(reminder); reminder.Init(); }
public void Load() { var command = DataStore.Connection.CreateCommand(); SqlCeDataReader reader = null; command.CommandText = "SELECT * FROM [reminders] ORDER BY [time]"; reader = command.ExecuteReader(); while(reader.Read()) { Reminder rem = new Reminder(this); rem.Name = reader.GetString("name"); rem.Text = reader.GetString("text"); rem.Time = reader.GetDateTime("time"); rem.Frequency = reader.GetEnum<Frequency>("frequency"); reminders.Add(rem); rem.Init(); } reader.Dispose(); command.Dispose(); }