Beispiel #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();
     }
 }
Beispiel #2
0
 public void Commit(System.Data.OleDb.OleDbConnection connection)
 {
     if (this[connection] != null && ((ConnectionProperties)this[connection]).AutoCommit)
     {
         System.Data.OleDb.OleDbTransaction transaction = ((ConnectionProperties)this[connection]).Transaction;
         transaction.Commit();
     }
 }
Beispiel #3
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();
            }
        }