protected void CreateComponent(DAL masterDAL, int compNum, ComponentDO compInfo, String compPath) { //copy master to create component file masterDAL.CopyTo(compPath); var compDB = new DAL(compPath); try { compDB.BeginTransaction(); compDB.Execute("DELETE FROM CountTree WHERE Component_CN IS NOT NULL;"); compDB.Execute(SQL.CLEAR_FIELD_DATA); string command = string.Format("UPDATE CountTree Set Component_CN = {0};", compInfo.Component_CN); compDB.Execute(command); //Set the starting rowID for each component compDB.SetTableAutoIncrementStart("Tree", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Log", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("TreeEstimate", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Stem", GetComponentRowIDStart(compNum)); compDB.SetTableAutoIncrementStart("Plot", compNum * PLOT_ROW_SPACING); compDB.Execute("DELETE FROM Globals WHERE Block = 'Comp' AND Key = 'ChildComponents';"); compDB.Execute("DELETE FROM Globals WHERE Block = 'Comp' AND Key = 'LastMerge';"); compDB.CommitTransaction(); } catch (Exception) { compDB.RollbackTransaction(); try { //component is probably jacked up, so delete it System.IO.File.Delete(compDB.Path); } catch { } //may throw exception if file doesn't exist, but we can ignore that } finally { compDB.Dispose(); } }