protected void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { if (transaction != null) { transaction.Dispose(); transaction = null; } } disposed = true; }
static private int ExecuteNonQuery(System.Data.SqlServerCe.SqlCeCommand command, bool useTransaction, out int out__rowid, bool findoutLastInsertId) { bool retry = false; bool trans_started = false; System.Data.SqlServerCe.SqlCeTransaction trans = null; try { if (useTransaction) { trans = command.Connection.BeginTransaction(); trans_started = true; command.Transaction = trans; } int rows_aff = command.ExecuteNonQuery(); int row_id = -1; if (findoutLastInsertId) { if (useTransaction) { row_id = GetLastInsertId(trans); } else { row_id = GetLastInsertId(); } } if (useTransaction) { trans.Commit(System.Data.SqlServerCe.CommitMode.Immediate); trans_started = false; command.Transaction = null; } out__rowid = row_id; return(rows_aff); } catch (System.Data.SqlServerCe.SqlCeException ex) { ////////MessageBox.Show(ex.Message + "\n" + "HRES = " + ex.HResult + "\n" + "ERRNO = " + ex.NativeError); if (useTransaction && trans_started) { SafeTransRollback(trans); trans.Dispose(); trans = null; command.Transaction = null; trans_started = false; } if (ex.NativeError == 0) { retry = true; } else { throw; } } if (retry) { command.Connection.Close(); command.Connection.Open(); if (useTransaction) { trans = command.Connection.BeginTransaction(); trans_started = true; command.Transaction = trans; } int rows_aff = command.ExecuteNonQuery(); int row_id = -1; if (findoutLastInsertId) { if (useTransaction) { row_id = GetLastInsertId(trans); } else { row_id = GetLastInsertId(); } } if (useTransaction) { trans.Commit(System.Data.SqlServerCe.CommitMode.Immediate); trans_started = false; command.Transaction = null; } out__rowid = row_id; return(rows_aff); } else { out__rowid = -1; return(0); } }