當前位置: 首頁>>代碼示例>>C#>>正文


C# MySqlClient.MySqlTransaction類代碼示例

本文整理匯總了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;
 }
開發者ID:seeseekey,項目名稱:CSCL,代碼行數:7,代碼來源:MySqlPromotableTransaction.cs

示例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();
                }
            }
        }
開發者ID:carriercomm,項目名稱:BillingSystem,代碼行數:27,代碼來源:MySqlDbHelper.cs

示例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;
        }
開發者ID:BenjaOtero,項目名稱:trend-pos,代碼行數:29,代碼來源:ArticulosDAL.cs

示例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;
        }
開發者ID:BenjaOtero,項目名稱:trend-gestion-desktop,代碼行數:34,代碼來源:TesoreriaMovimientosDAL.cs

示例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];
 }
開發者ID:ullassagar,項目名稱:eshop,代碼行數:7,代碼來源:MysqlRepository.cs

示例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;
            }
        }
開發者ID:jspengine,項目名稱:SIGPA-DIGITAL,代碼行數:30,代碼來源:DALParametros.cs

示例7: MySqlCommand

		/// <include file='docs/mysqlcommand.xml' path='docs/ctor4/*'/>
		public MySqlCommand(string cmdText, MySqlConnection connection,
				MySqlTransaction transaction)
			:
			this(cmdText, connection)
		{
			curTransaction = transaction;
		}
開發者ID:maanshancss,項目名稱:ClassLibrary,代碼行數:8,代碼來源:command.cs

示例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;
 }
開發者ID:freaky0112,項目名稱:SocketTest,代碼行數:19,代碼來源:MysqlHelper.cs

示例9: MySqlCommand

		public MySqlCommand(string commandText, MySqlConnection connection, MySqlTransaction transaction)
		{
			CommandText = commandText;
			DbConnection = connection;
			DbTransaction = transaction;
			m_parameterCollection = new MySqlParameterCollection();
		}
開發者ID:yaozhenfa,項目名稱:MySqlConnector,代碼行數:7,代碼來源:MySqlCommand.cs

示例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);
                }

            }
        }
開發者ID:yeti0506,項目名稱:MySqlIdentity,代碼行數:25,代碼來源:MySqlHelper.cs

示例11: MasterPOSConnection

        public MasterPOSConnection(MySqlConnection Connection, MySqlTransaction Transaction)
        {
            mConnection = Connection;
            mTransaction = Transaction;

            GetConnection();
        }
開發者ID:marioricci,項目名稱:erp-luma,代碼行數:7,代碼來源:MasterMySqlDataConnection.cs

示例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);
        }
開發者ID:JulianoW,項目名稱:ffrkx,代碼行數:7,代碼來源:DbOpRecordDungeonList.cs

示例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();
        }
開發者ID:rpertence,項目名稱:AmorPraBicho,代碼行數:8,代碼來源:conexao.cs

示例14: init

            private void init(string connString) {
                connection = new MySqlConnection(connString);
                connection.Open();
                connection.ChangeDatabase(Server.MySQLDatabaseName);

                transaction = connection.BeginTransaction();
            }
開發者ID:tommyz56,項目名稱:MCGalaxy,代碼行數:7,代碼來源:MySQLTransactionHelper.cs

示例15: CommitTran

 public void CommitTran()
 {
     if (_tran != null)
     {
         _tran.Commit();
         _tran = null;
     }
 }
開發者ID:webxiaohua,項目名稱:SmartORM,代碼行數:8,代碼來源:MySQLHelper.cs


注:本文中的MySql.Data.MySqlClient.MySqlTransaction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。