public void Insert() { IDbTransaction transaction = null; try { // Create a transaction to ensure all child properties are inserted along with the student record transaction = DataServiceBase.BeginTransaction(); //Create a Student Data Service object with the transction object StudentDataService dataService = new StudentDataService(transaction); //Call the insert method dataService.Insert(_studentID, _last4Ssn, _firstName, _lastName, _phoneCell, _phoneDay, _phoneEvening, _email, _address, _city, _state, _zipcode, _gpa, _graduationDate); // Insert the Internship Requirement Child Object with the transaction _internshipRequirement.Insert(_studentID, transaction); // Insert employer if exists if (_employer != null) { _employer.Insert(_studentID, transaction); } // Commit the Transaction, ensures all child properites are saved along with the studento Objects transaction.Commit(); } /*catch * { * // Remove all records from the database if an error occurs * transaction.Rollback(); * throw; * }*/ catch (Exception ex) { // Remove all records from the database if an error occurs transaction.Rollback(); // throw new System.Exception(ex.Message); throw new System.Exception("Exception: '" + ex.Message + "' occured while inserting data! All transactions have been removed from database!"); } }