public static Company GetCompany(int?id) { using (SqlConnection con = new SqlConnection(connString, credentials)) { try { if (id is null) { return(null); } Dictionary <string, object> p = new Dictionary <string, object> { { "@Id", id } }; string query = "SELECT Id, Name, Title, Country " + "FROM Companies " + "WHERE Id = @Id"; con.Open(); return(DBActions.ExecReaderQR <Company>(con, query, p)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } finally { con.Close(); } } }