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


C# OleDb.OleDbTransaction类代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbTransaction的典型用法代码示例。如果您正苦于以下问题:C# OleDbTransaction类的具体用法?C# OleDbTransaction怎么用?C# OleDbTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OleDbTransaction类属于System.Data.OleDb命名空间,在下文中一共展示了OleDbTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAddProductCommand

        public OleDbCommand CreateAddProductCommand(OleDbConnection conn, OleDbTransaction transaction)
        {
            var cmd = new OleDbCommand(ConvertToOleDbQuery(_sql), conn, transaction);
            CreateParameters(cmd);

            return cmd;
        }
开发者ID:cwbrandsma,项目名称:FluentAdo,代码行数:7,代码来源:InsertPerformanceTests.cs

示例2: DeleteList

 /// <summary>
 /// ²éÕÒ²»´æÔÚµÄͼƬ²¢É¾³ýÒÑɾ³ýµÄͼƬ¼°Êý¾Ý
 /// </summary>
 public void DeleteList(OleDbConnection conn, OleDbTransaction trans, List<Model.article_albums> models, int article_id)
 {
     StringBuilder idList = new StringBuilder();
     if (models != null)
     {
         foreach (Model.article_albums modelt in models)
         {
             if (modelt.id > 0)
             {
                 idList.Append(modelt.id + ",");
             }
         }
     }
     string id_list = Utils.DelLastChar(idList.ToString(), ",");
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select id,big_img,small_img from dt_article_albums where article_id=" + article_id);
     if (!string.IsNullOrEmpty(id_list))
     {
         strSql.Append(" and id not in(" + id_list + ")");
     }
     DataSet ds = DbHelperOleDb.Query(conn, trans, strSql.ToString());
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         int rows = DbHelperOleDb.ExecuteSql(conn, trans, "delete from dt_article_albums where id=" + dr["id"].ToString()); //ɾ³ýÊý¾Ý¿â
         if (rows > 0)
         {
             Utils.DeleteFile(dr["big_img"].ToString()); //ɾ³ýԭͼ
             Utils.DeleteFile(dr["small_img"].ToString()); //ɾ³ýËõÂÔͼ
         }
     }
 }
开发者ID:sichina,项目名称:or-dtcms2.0,代码行数:34,代码来源:article_albums.cs

示例3: DeleteList

 /// <summary>
 /// 查找不存在的图片并删除已删除的图片及数据
 /// </summary>
 public void DeleteList(OleDbConnection conn, OleDbTransaction trans, List<Model.article_albums> models, int article_id)
 {
     StringBuilder idList = new StringBuilder();
     if (models != null)
     {
         foreach (Model.article_albums modelt in models)
         {
             if (modelt.id > 0)
             {
                 idList.Append(modelt.id + ",");
             }
         }
     }
     string id_list = Utils.DelLastChar(idList.ToString(), ",");
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select id,thumb_path,original_path from " + databaseprefix + "article_albums where article_id=" + article_id);
     if (!string.IsNullOrEmpty(id_list))
     {
         strSql.Append(" and id not in(" + id_list + ")");
     }
     DataSet ds = DbHelperOleDb.Query(conn, trans, strSql.ToString());
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         int rows = DbHelperOleDb.ExecuteSql(conn, trans, "delete from " + databaseprefix + "article_albums where id=" + dr["id"].ToString()); //删除数据库
         if (rows > 0)
         {
             Utils.DeleteFile(dr["thumb_path"].ToString()); //删除缩略图
             Utils.DeleteFile(dr["original_path"].ToString()); //删除原图
         }
     }
 }
开发者ID:sfwjiao,项目名称:MyTestProject,代码行数:34,代码来源:article_albums.cs

示例4: PrepareCommand

		/// <summary>
		/// This method opens (if necessary) and assigns a connection, transaction, command type and parameters 
		/// to the provided command.
		/// </summary>
		/// <param name="command">the OleDbCommand to be prepared</param>
		/// <param name="connection">a valid OleDbConnection, on which to execute this command</param>
		/// <param name="transaction">a valid OleDbTransaction, or 'null'</param>
		/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
		/// <param name="commandText">the stored procedure name or PL/SQL command</param> 
		/// <param name="commandParameters">an array of OleDbParameters to be associated with the command or 'null' if no parameters are required</param>
		private static void PrepareCommand( OleDbCommand command, OleDbConnection connection, OleDbTransaction transaction, CommandType commandType, string commandText, OleDbParameter[] commandParameters )
		{
			//if the provided connection is not open, we will open it
			if( connection.State != ConnectionState.Open )
			{
				connection.Open();
			}

			//associate the connection with the command
			command.Connection = connection;

			//set the command text (stored procedure name or OleDb statement)
			command.CommandText = commandText;

			//if we were provided a transaction, assign it.
			if( transaction != null )
			{
				command.Transaction = transaction;
			}

			//set the command type
			command.CommandType = commandType;

			//attach the command parameters if they are provided
			if( commandParameters != null )
			{
				AttachParameters( command, commandParameters );
			}

			return;
		}
开发者ID:jinweijie,项目名称:Goldtect.ASTreeViewSamples,代码行数:41,代码来源:OleDbHelper.cs

示例5: AsDataSource

        /// <summary>
        /// Returns a data source wrapped around the transaction.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="transaction">The transaction.</param>
        /// <returns>SqlServerOpenDataSource.</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static AccessOpenDataSource AsDataSource(this OleDbConnection connection, OleDbTransaction transaction)
        {
            if (connection == null)
                throw new ArgumentNullException(nameof(connection), $"{nameof(connection)} is null.");
            if (connection.State == ConnectionState.Closed)
                connection.Open();

            var dataSourceBase = s_CachedDataSources.GetOrAdd(connection.ConnectionString, cs => new AccessDataSource(cs));
            return new AccessOpenDataSource(dataSourceBase, connection, transaction);
        }
开发者ID:docevaad,项目名称:Chain,代码行数:17,代码来源:AccessExtensions.cs

示例6: ExecuteNoQuery

 public static int ExecuteNoQuery(CommandType commType, string commText, OleDbParameter[] param, OleDbTransaction tran)
 {
     int result = 0;
     using (OleDbConnection conn = new OleDbConnection(connectString))
     {
         PrepareCommand(conn, comm, commType, commText, param, tran);
         result = comm.ExecuteNonQuery();
     }
     return result;
 }
开发者ID:hanwest00,项目名称:HXMail,代码行数:10,代码来源:AccessHelper.cs

示例7: OleDbCustomCommandBuilder

		public OleDbCustomCommandBuilder( DataTable dataTable, OleDbConnection connection, ArrayList columnOleDbTypes, OleDbTransaction transaction)
		{
			if (dataTable.Columns.Count != columnOleDbTypes.Count){
				throw new ArgumentException("Number of OleDbTypes does not match number of columns.");
			}
			this.dataTable = dataTable;
			this.connection = connection;
			this.columnOleDbTypes = columnOleDbTypes;
			this.transaction = transaction;
		}
开发者ID:aureliopires,项目名称:gisa,代码行数:10,代码来源:OleDbCustomCommandBuilder.cs

示例8: GenerateDay

 void GenerateDay(OleDbConnection connection, OleDbTransaction transaction, int n, DateTime day) {
     double totalDays = day.Subtract(minRequiredDate).TotalDays;
     int salesPerDay = random.Next(180, (int)(200 * (1 + (totalDays * dailySalesGrowth) / 10)));
     int[] generateIntervals = GenerateTimeIntervals(salesPerDay);
     DateTime start = new DateTime(day.Year, day.Month, day.Day, startTime, 0, 0);
     for(int d = 0; d < generateIntervals.Length; d++) {
         for(int x = 0; x < generateIntervals[d]; x++)
             GenerateSale(connection, transaction, start);
         start = start.AddMinutes(timeInterval);
     }
 }
开发者ID:shine8319,项目名称:DLS,代码行数:11,代码来源:SalesDBGenerator.cs

示例9: BeginTransaction

 public void BeginTransaction()
 {
     this.Open();
     this.cmd = this.connection.CreateCommand();
     this.transaction = this.connection.BeginTransaction();
     this.cmd.Transaction = this.transaction;
 }
开发者ID:huaminglee,项目名称:hfoa,代码行数:7,代码来源:OleDBOperator.cs

示例10: Commit

 public void Commit()
 {
     if (connection==null) throw new PersistException("No current connection");
     if (transaction==null) throw new PersistException("No transaction to commit");
     transaction.Commit();
     transaction=null;
 }
开发者ID:flyingoverclouds,项目名称:sfinx,代码行数:7,代码来源:OLEDBHelper.cs

示例11: Init

        private void Init(JetProcessor processor, IEnumerable<string> columnDefinitions)
        {
            Connection = processor.Connection;
            Transaction = processor.Transaction;

            Create(columnDefinitions);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:JetTestTable.cs

示例12: DBBase

 public DBBase(IDbConnection conn)
 {
     this._connection = null;
     this._transaction = null;
     this.DB_Driver_Type = "OleDb";
     this._connection = (OleDbConnection) conn;
 }
开发者ID:SoMeTech,项目名称:SoMeRegulatory,代码行数:7,代码来源:DBBase.cs

示例13: TestBeginTransactionChaos

		public void TestBeginTransactionChaos() {

			DataBaseServer dbType = ConnectedDataProvider.GetDbType(con);
			// not supported on DB2 and Oracle and Sybase
			if (dbType != DataBaseServer.Oracle && dbType != DataBaseServer.DB2 && dbType != DataBaseServer.Sybase) {
				con.Close();
				con.Open();
				try {
					BeginCase("BeginTransaction - IsolationLevel Chaos");
					tran = con.BeginTransaction(IsolationLevel.Chaos);
					Compare(tran == null, false);
				} 
				catch(Exception ex){exp = ex;}
				finally{EndCase(exp); exp = null;}
			}
			/*	not supported by MSSQL,DB2,Oracle
				con.Close();
				con.Open();
				try
				{
					BeginCase("BeginTransaction - IsolationLevel Unspecified");
					tran = con.BeginTransaction(IsolationLevel.Unspecified );
					Compare(tran == null, false);
				} 
				catch(Exception ex){exp = ex;}
				finally{EndCase(exp); exp = null;}
			*/
			
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:OleDbConnection_BeginTransaction.cs

示例14: WorkDB

 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="aConnectionString">строка соединения</param>
 public WorkDB(string aConnectionString)
 {
     mCn = new OleDbConnection(aConnectionString);
     mErr = new Error();
       mTxn = null;
       mIsInternalTransaction = false;
 }
开发者ID:infobook,项目名称:Query3,代码行数:11,代码来源:WorkDB.cs

示例15: product_service

        public int product_service(string service_id, string product_id, int customer_id)
        {
            int row=0;

               cn = new OleDbConnection("Provider=MSDAORA;Data Source=192.168.0.217/orcl;Persist Security Info=True;User ID=hr;Password=hr;");

            cmd = cn.CreateCommand();
            try
            {
                cn.Open();

                string s = "update product_services set product_id='" + product_id + "' where service_id=(select service_id from customer_services where customer_id=" + customer_id + " and service_id='" + service_id + "')";
                Trans = cn.BeginTransaction();
                cmd = new OleDbCommand(s, cn,Trans);
                cmd.Transaction = Trans;
                row= cmd.ExecuteNonQuery();
                Trans.Commit();

            }
            catch (Exception e)
            {
                string s = e.Message;
                Trans.Rollback();
            }
            finally
            {
                cn.Close();
            }
            return row;
        }
开发者ID:shiva94,项目名称:SelfServiceSales_Full,代码行数:30,代码来源:Service1.asmx.cs


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