コード例 #1
0
 protected override void DataAdapterUpdate(System.Data.DataSet tabela, string strNomeTabela)
 {
     if (m_bUserCanUpdateDB)
     {
         OpenConnection();
         if (m_Connection.State == System.Data.ConnectionState.Open)
         {
             if (tabela.GetChanges() != null)
             {
                 m_Transaction = m_Connection.BeginTransaction();
                 m_CommandSelect.Transaction = m_Transaction;
                 try
                 {
                     m_DataAdapter.Update(tabela, strNomeTabela);
                     m_Transaction.Commit();
                     DataPersist = false;
                 }
                 catch (System.Exception eEcp)
                 {
                     m_excError        = eEcp;
                     m_excError.Source = strNomeTabela;
                     m_Transaction.Rollback();
                     ShowDialogUpdateError(strNomeTabela);
                 }
             }
         }
         CloseConnection();
     }
 }
コード例 #2
0
 public void RollBack(System.Data.OleDb.OleDbConnection connection)
 {
     if (this[connection] != null && ((ConnectionProperties)this[connection]).AutoCommit)
     {
         System.Data.OleDb.OleDbTransaction transaction = ((ConnectionProperties)this[connection]).Transaction;
         transaction.Rollback();
     }
 }
コード例 #3
0
 public static void DeshacerTransaccion()
 {
     if (transaccion != null)
     {
         try
         {
             transaccion.Rollback();
         }
         catch (System.Exception)
         {
         }
     }
コード例 #4
0
        public static void  DBLogOut(UpdateLog[] logDatas)
        {
            if (System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"] == null)
            {
                return;
            }
            string connString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].Trim();

            connString = BenQGuru.eMES.Common.Helper.EncryptionHelper.DESDecryption(connString);
            System.Data.OleDb.OleDbConnection  conn  = new System.Data.OleDb.OleDbConnection(connString);
            System.Data.OleDb.OleDbTransaction trans = null;
            try
            {
                conn.Open();

                System.Data.OleDb.OleDbCommand comm = conn.CreateCommand();

                trans            = conn.BeginTransaction();
                comm.Transaction = trans;
                foreach (UpdateLog log in logDatas)
                {
                    string updateSQL = "INSERT INTO TBLUPDATELOG "
                                       + " (UPDATELOGID,FILENAME,VERSION,MACHINENAME,MACHINEIP,UPDATETIME,RESULT)"
                                       + " values ('" + log.PKID + "'"
                                       + " ,'" + log.FileName + "'"
                                       + " ,'" + log.Version + "'"
                                       + " ,'" + log.MachineName + "'"
                                       + " ,'" + log.MachineIP + "'"
                                       + " ,'" + log.UpdateTime + "'"
                                       + " ,'" + log.Result + "')";

                    comm.CommandText = updateSQL;
                    comm.CommandType = System.Data.CommandType.Text;
                    comm.ExecuteNonQuery();
                }
                trans.Commit();
            }
            catch (Exception ex)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #5
0
ファイル: sql.cs プロジェクト: apamojica16/ConsultarTarjeta
        public string EjecutarSQL1()//este metodo se usa para operaciones de crear, modificar y eliminar
        {
            try
            {
                // System.Data.OleDb.OleDbCommand miComando = new System.Data.OleDb.OleDbCommand();
                //miComando.Connection=conn;//se relaciona el objeto comando con el objeto conexion
                MiConexion.Open();//abri la conexion
                SqlCommand MiComando = new SqlCommand(sentenciaSQL1, MiConexion);
                MiComando.ExecuteNonQuery();
                //string g = MiComando.ExecuteScalar().ToString();

                return("Todo OK");
            }
            catch (Exception e)
            {
                miTran.Rollback();// anula operacion
                return("Se presento el siguiente error " + e.Message);
            }
            finally
            {
                MiConexion.Close();
            }
        }