private void SearchExamRecord() { string query = ConstructSearchQuery(); MainViewModel.OpenDbConnection(true); try { SQLiteDataAdapter adapt = new SQLiteDataAdapter(query, DatabaseInfo.SqliteCon); DataTable table = new DataTable(); adapt.Fill(table); ObservableCollection <Patient> patients = new ObservableCollection <Patient>(); foreach (DataRow row in table.Rows) { string accNumber = ((long)row[accountNumberCol]).ToString(); string fName = (string)row[firstNameCol]; string lName = (string)row[lastNameCol]; string examDate = (string)row[examDateCol]; Patient pt = new Patient(accNumber, fName, lName, examDate, false); patients.Add(pt); } PatientRecords = patients; DatabaseInfo.CloseDbConnection(); } catch (Exception) { DatabaseInfo.CloseDbConnection(); throw; } }
public static void CloseDbConnection() { DatabaseInfo.CloseDbConnection(); }