当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteTransaction.Rollback方法代码示例

本文整理汇总了C#中System.Data.SQLite.SQLiteTransaction.Rollback方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteTransaction.Rollback方法的具体用法?C# SQLiteTransaction.Rollback怎么用?C# SQLiteTransaction.Rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SQLite.SQLiteTransaction的用法示例。


在下文中一共展示了SQLiteTransaction.Rollback方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TransactionHandler

        /// <summary>
        ///Description	    :	This function is used to Handle Transaction Events
        ///Author			:	AuthorWho
        ///Date				:	2011-11-01
        ///Input			:	Transaction Event Type
        ///OutPut			:	NA
        ///Comments			:	
        /// </summary>
        public void TransactionHandler(TransactionType veTransactionType)
        {
            switch (veTransactionType)
            {
                case TransactionType.Open:  //open a transaction
                    try
                    {
                        oTransaction    = oConnection.BeginTransaction();
                        mblTransaction  = true;
                    }
                    catch (InvalidOperationException oErr)
                    {
                        throw new Exception("@TransactionHandler - " + oErr.Message);
                    }
                    break;

                case TransactionType.Commit:  //commit the transaction
                    if (null != oTransaction.Connection)
                    {
                        try
                        {
                            oTransaction.Commit();
                            mblTransaction = false;
                        }
                        catch (InvalidOperationException oErr)
                        {
                            throw new Exception("@TransactionHandler - " + oErr.Message);
                        }
                    }
                    break;

                case TransactionType.Rollback:  //rollback the transaction
                    try
                    {
                        if (mblTransaction)
                        {
                            oTransaction.Rollback();
                        }
                        mblTransaction = false;
                    }
                    catch (InvalidOperationException oErr)
                    {
                        throw new Exception("@TransactionHandler - " + oErr.Message);
                    }
                    break;
            }
        }
开发者ID:xlgwr,项目名称:RFID,代码行数:55,代码来源:SQLiteHelper.cs

示例2: CommitTransaction

 /* Commits the transaction. If it fails, the transaction is rolled back and an error 
  * message is opened. Returns true upon success, else false.
  */
 public bool CommitTransaction(SQLiteTransaction transaction)
 {
     try
     {
         transaction.Commit();
     }
     catch (Exception)
     {
         try
         {
             transaction.Rollback();
             MessageBox.Show("CommitTransaction", "Database access failed",
                 MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         catch (Exception)
         {
             MessageBox.Show("CommitTransaction", "Database access and rollback failed",
                 MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         return false;
     }
     return true;
 }
开发者ID:danilind,项目名称:workoutlogger,代码行数:26,代码来源:Database.cs

示例3: Roolback

 public static bool Roolback(SQLiteTransaction aTransaction)
 {
     try
     {
         aTransaction.Rollback();
         return true;
     }
     catch (Exception aExc)
     {
         log.Fatal("Can´t Rollback changes in database!", aExc);
     }
     return false;
 }
开发者ID:Zigi34,项目名称:ReaderDiary,代码行数:13,代码来源:Database.cs

示例4: Command

 public int Command(string cmdstr)
 {
     try
     {
         T = conn.BeginTransaction();
         cmd.Transaction = T;
         cmd.CommandText = cmdstr;
         int a = cmd.ExecuteNonQuery();
         T.Commit();
         return a;
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message,"错误提示");
         T.Rollback();
         return -1;
     }
     finally
     {
         T.Dispose();
     }
 }
开发者ID:cs164325,项目名称:cc,代码行数:22,代码来源:Access.cs

示例5: RollbackTransaction

        protected void RollbackTransaction(SQLiteTransaction transaction)
        {
            try
            {
                transaction.Rollback();
            }
            catch (Exception ex)
            {
                _log.Error("Unable to rollback transaction.", ex);

                throw new StorageException("Unable to rollback transaction.", ex);
            }
        }
开发者ID:blacker-cz,项目名称:MangaScraper,代码行数:13,代码来源:SQLiteDALBase.cs

示例6: insertData

        /// <summary>
        /// Insert big Data with transaction
        /// </summary>
        /// <param name="command">sqlite command seperated with ;</param>
        public void insertData(string command)
        {
            try
            {
                string[] cmd = command.Split(';');
                Connect();
                sql_con.Open();

                sql_cmd = new SQLiteCommand();

                // Start a local transaction
                sql_trans = sql_con.BeginTransaction(IsolationLevel.Serializable);
                // Assign transaction object for a pending local transaction
                sql_cmd.Transaction = sql_trans;

                for (int i = 0; i < cmd.Length; i++)
                {
                    if (cmd[i] != "")
                    {
                        sql_cmd.CommandText = cmd[i].Trim();
                        sql_cmd.ExecuteNonQuery();
                    }
                }
                sql_trans.Commit();
            }
            catch (Exception e)
            {
                sql_trans.Rollback();
                message = "Error insertData: Non of the data has been inserted to Database\r\n\r\n" + e.ToString();
                success = false;
                sql_con.Close();
            }
            finally
            {
                sql_con.Close();
                message = "Success insertData";
                success = true;
            }
        }
开发者ID:phylroy,项目名称:ep-database,代码行数:43,代码来源:SqliteDB.cs

示例7: ExecuteUpdate

        protected void ExecuteUpdate(String sql, SQLiteTransaction trans)
        {
            if (!IsOpen)
                OpenDB();

            SQLiteCommand update = _dbConnection.CreateCommand();

            try
            {
                update.Transaction = trans;
                update.CommandText = sql.ToString();
                try
                {
                    update.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    trans.Rollback();
                    throw;
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessLayer:ExecuteUpdate");
            }
            finally
            {
                update.Dispose();
            }
        }
开发者ID:FMSC-Measurements,项目名称:TwoTrailsV2,代码行数:30,代码来源:DataAccessLayer.cs


注:本文中的System.Data.SQLite.SQLiteTransaction.Rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。