本文整理汇总了C#中MySql.Data.MySqlClient.MySqlTransaction类的典型用法代码示例。如果您正苦于以下问题:C# MySqlTransaction类的具体用法?C# MySqlTransaction怎么用?C# MySqlTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlTransaction类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MySqlTransactionScope
public MySqlTransactionScope(MySqlConnection con, Transaction trans,
MySqlTransaction simpleTransaction)
{
connection = con;
baseTransaction = trans;
this.simpleTransaction = simpleTransaction;
}
示例2: ExecuteCommand
//带参数的执行命令
public static int ExecuteCommand(MySqlTransaction mySqlTransaction,string sql, params MySqlParameter[] values)
{
using (MySqlConnection connection = new MySqlConnection(connectionString))
{
try
{
connection.Open();
mySqlTransaction = connection.BeginTransaction();
MySqlCommand cmd = new MySqlCommand(sql, connection, mySqlTransaction);
cmd.Parameters.AddRange(values);
cmd.ExecuteNonQuery(); // ExecuteNonQuery()一般用于UPDATE、INSERT或DELETE语句,其中唯一的返回值是受影响的记录个数
mySqlTransaction.Commit();
return 1;
}
catch
{
mySqlTransaction.Rollback();
return 0;
}
finally
{
connection.Close();
}
}
}
示例3: AdaptadorInsert
private static MySqlDataAdapter AdaptadorInsert(MySqlConnection SqlConnection1, MySqlTransaction tr)
{
SqlDataAdapter1 = new MySqlDataAdapter();
SqlInsertCommand1 = new MySqlCommand("Articulos_Insertar", SqlConnection1);
SqlInsertCommand1.Transaction = tr;
SqlDataAdapter1.InsertCommand = SqlInsertCommand1;
// IMPLEMENTACIÓN DE LA ORDEN INSERT
SqlInsertCommand1.Parameters.Add("p_id", MySqlDbType.VarChar, 55, "IdArticuloART");
SqlInsertCommand1.Parameters.Add("p_idItem", MySqlDbType.Int32, 11, "IdItemART");
SqlInsertCommand1.Parameters.Add("p_idColor", MySqlDbType.Int32, 11, "IdColorART");
SqlInsertCommand1.Parameters.Add("p_idAlicuota", MySqlDbType.Int16, 3, "IdAliculotaIvaART");
SqlInsertCommand1.Parameters.Add("p_talle", MySqlDbType.VarChar, 50, "TalleART");
SqlInsertCommand1.Parameters.Add("p_idProveedor", MySqlDbType.Int32, 11, "IdProveedorART");
SqlInsertCommand1.Parameters.Add("p_descripcion", MySqlDbType.VarChar, 55, "DescripcionART");
SqlInsertCommand1.Parameters.Add("p_descripcionWeb", MySqlDbType.VarChar, 50, "DescripcionWebART");
SqlInsertCommand1.Parameters.Add("p_precioCosto", MySqlDbType.Decimal, 19, "PrecioCostoART");
SqlInsertCommand1.Parameters.Add("p_precioPublico", MySqlDbType.Decimal, 19, "PrecioPublicoART");
SqlInsertCommand1.Parameters.Add("p_precioMayor", MySqlDbType.Decimal, 19, "PrecioMayorART");
SqlInsertCommand1.Parameters.Add("p_fecha", MySqlDbType.DateTime, 19, "FechaART");
SqlInsertCommand1.Parameters.Add("p_imagen", MySqlDbType.VarChar, 50, "ImagenART");
SqlInsertCommand1.Parameters.Add("p_imagenBack", MySqlDbType.VarChar, 50, "ImagenBackART");
SqlInsertCommand1.Parameters.Add("p_imagenColor", MySqlDbType.VarChar, 50, "ImagenColorART");
SqlInsertCommand1.Parameters.Add("p_activoWeb", MySqlDbType.Int32, 1, "ActivoWebART");
SqlInsertCommand1.Parameters.Add("p_nuevo", MySqlDbType.Int32, 1, "NuevoART");
SqlInsertCommand1.CommandType = CommandType.StoredProcedure;
return SqlDataAdapter1;
}
示例4: AdaptadorABM
private static MySqlDataAdapter AdaptadorABM(MySqlConnection SqlConnection1, MySqlTransaction tr)
{
SqlDataAdapter1 = new MySqlDataAdapter();
SqlInsertCommand1 = new MySqlCommand("TesoreriaMov_Insertar", SqlConnection1);
SqlUpdateCommand1 = new MySqlCommand("TesoreriaMov_Actualizar", SqlConnection1);
SqlDeleteCommand1 = new MySqlCommand("TesoreriaMov_Borrar", SqlConnection1);
SqlInsertCommand1.Transaction = tr;
SqlUpdateCommand1.Transaction = tr;
SqlDeleteCommand1.Transaction = tr;
SqlDataAdapter1.DeleteCommand = SqlDeleteCommand1;
SqlDataAdapter1.InsertCommand = SqlInsertCommand1;
SqlDataAdapter1.UpdateCommand = SqlUpdateCommand1;
// IMPLEMENTACIÓN DE LA ORDEN UPDATE
SqlUpdateCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 11, "IdMovTESM");
SqlUpdateCommand1.Parameters.Add("p_fecha", MySqlDbType.DateTime, 20,"FechaTESM");
SqlUpdateCommand1.Parameters.Add("p_pc", MySqlDbType.Int32, 11, "IdPcTESM");
SqlUpdateCommand1.Parameters.Add("p_detalle", MySqlDbType.VarChar, 200, "DetalleTESM");
SqlUpdateCommand1.Parameters.Add("p_importe", MySqlDbType.Double, 50, "ImporteTESM");
SqlUpdateCommand1.CommandType = CommandType.StoredProcedure;
// IMPLEMENTACIÓN DE LA ORDEN INSERT
SqlInsertCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 11, "IdMovTESM");
SqlInsertCommand1.Parameters.Add("p_fecha", MySqlDbType.DateTime, 20, "FechaTESM");
SqlInsertCommand1.Parameters.Add("p_pc", MySqlDbType.Int32, 11, "IdPcTESM");
SqlInsertCommand1.Parameters.Add("p_detalle", MySqlDbType.VarChar, 200, "DetalleTESM");
SqlInsertCommand1.Parameters.Add("p_importe", MySqlDbType.Double, 50, "ImporteTESM");
SqlInsertCommand1.CommandType = CommandType.StoredProcedure;
// IMPLEMENTACIÓN DE LA ORDEN DELETE
SqlDeleteCommand1.Parameters.Add("p_id", MySqlDbType.Int32, 11, "IdMovTESM");
SqlDeleteCommand1.CommandType = CommandType.StoredProcedure;
return SqlDataAdapter1;
}
示例5: ExecuteDatarow
public static DataRow ExecuteDatarow(MySqlConnection connection, MySqlTransaction transaction, string commandText, params MySqlParameter[] parms)
{
var dt = ExecuteDataTable(connection, transaction, commandText, parms);
if (dt == null) return null;
if (dt.Rows.Count == 0) return null;
return dt.Rows[0];
}
示例6: dbAtualizarContador
public Boolean dbAtualizarContador(INFOParametros pObjParametros, MySqlTransaction pObjTrans)
{
StringBuilder strSQL = null;
double contador = pObjParametros.NumeroContador + 1;
try
{
strSQL = new StringBuilder();
strSQL.AppendLine("UPDATE parametros SET ");
strSQL.AppendLine(" NR_CONTADOR = " + contador);
if (dbExecutarQuery(strSQL.ToString(), pObjTrans) > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
strSQL = null;
}
}
示例7: MySqlCommand
/// <include file='docs/mysqlcommand.xml' path='docs/ctor4/*'/>
public MySqlCommand(string cmdText, MySqlConnection connection,
MySqlTransaction transaction)
:
this(cmdText, connection)
{
curTransaction = transaction;
}
示例8: ExecuteNonQuery
/// <summary>
///使用现有的SQL事务执行一个sql命令(不返回数据集)
/// </summary>
/// <remarks>
///举例:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24));
/// </remarks>
/// <param name="trans">一个现有的事务</param>
/// <param name="cmdType">命令类型(存储过程, 文本, 等等)</param>
/// <param name="cmdText">存储过程名称或者sql命令语句</param>
/// <param name="commandParameters">执行命令所用参数的集合</param>
/// <returns>执行命令所影响的行数</returns>
public static int ExecuteNonQuery(MySqlTransaction trans, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) {
MySqlCommand cmd = new MySqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
示例9: MySqlCommand
public MySqlCommand(string commandText, MySqlConnection connection, MySqlTransaction transaction)
{
CommandText = commandText;
DbConnection = connection;
DbTransaction = transaction;
m_parameterCollection = new MySqlParameterCollection();
}
示例10: PrepareCommand
private static void PrepareCommand(MySqlCommand cmd, MySqlConnection conn, MySqlTransaction trans, CommandType cmdType, string cmdText, Dictionary<string, object> cmdParms)
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
cmd.Connection = conn;
cmd.CommandText = cmdText;
if (trans != null)
{
cmd.Transaction = trans;
}
cmd.CommandType = cmdType;
if (cmdParms != null)
{
foreach (var param in cmdParms)
{
var parameter = cmd.CreateParameter();
parameter.ParameterName = param.Key;
parameter.Value = param.Value;
cmd.Parameters.Add(parameter);
}
}
}
示例11: MasterPOSConnection
public MasterPOSConnection(MySqlConnection Connection, MySqlTransaction Transaction)
{
mConnection = Connection;
mTransaction = Transaction;
GetConnection();
}
示例12: Execute
public void Execute(MySqlConnection connection, MySqlTransaction transaction)
{
CallProcInsertWorldEntry(connection, transaction, mDungeonList.World);
foreach (DataDungeon dungeon in mDungeonList.Dungeons)
CallProcInsertDungeonEntry(connection, transaction, mDungeonList.World, dungeon);
}
示例13: ExecuteScalar
public static string ExecuteScalar(string SQL, MySqlConnection conn, MySqlTransaction tran)
{
if (conn.State != ConnectionState.Open)
conn.Open();
MySqlCommand cmd = new MySqlCommand(SQL, conn, tran);
return cmd.ExecuteScalar().ToString();
}
示例14: init
private void init(string connString) {
connection = new MySqlConnection(connString);
connection.Open();
connection.ChangeDatabase(Server.MySQLDatabaseName);
transaction = connection.BeginTransaction();
}
示例15: CommitTran
public void CommitTran()
{
if (_tran != null)
{
_tran.Commit();
_tran = null;
}
}