I would like to check the results from a C# database call to make sure ..
- The DataTable returned is NOT NULL
- The DataTable has rows (DataTable.Rows.Count > 1)
If either of these conditions are true I want to return the same exception as this type of result is not expected, there should always some records. Is there a way to do this without repeating the throw exception statement?
if (myDataTable != null) { if (myDataTable.Rows.Count > 0) { myRow = myDataTable.Rows[0]; } else { throw new Exception("Problem obtaining data"); } } else { throw new Exception("Problem obtaining data"); } I don't need to differentiate between these exceptions for my purposes.