本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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;
}
}
示例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();
}
}