public static VoiceMemo QueryLatestVoiceMemo() { VoiceMemo memo = new VoiceMemo(); using (SqliteConnection connection = OpenDatabase()) { using (SqliteCommand command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM TVoiceMemos WHERE voiceMemoID = (SELECT MAX(voiceMemoID) From TVoiceMemos)"; SqliteDataReader reader = command.ExecuteReader(); reader.Read(); memo = VoiceMemo.FromDataRow(reader); reader.Close(); } } return(memo); }
public static List <VoiceMemo> QueryAllVoiceMemos() { List <VoiceMemo> voiceMemos = new List <VoiceMemo>(); string query = @"Select voiceMemoID, fileName, displayName, recordingDuration, filePath, recordDate, recordTime From TVoiceMemos ORDER BY recordDate, recordTime;"; using (SqliteConnection connection = OpenDatabase()) { SqliteCommand command = connection.CreateCommand(); command.CommandText = query; using (SqliteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { voiceMemos.Add(VoiceMemo.FromDataRow(reader)); } } } return(voiceMemos); }