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


C# OracleConnection.BeginTransaction方法代码示例

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


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

示例1: run

		public void run()
		{
			Exception exp = null;

			OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
			OracleTransaction txn = null;

			try
			{
				BeginCase("BeginTransaction - connection close");
				try
				{
					txn = con.BeginTransaction();
				}
				catch (Exception ex) {exp = ex;}
				Compare(exp.GetType().FullName ,typeof(InvalidOperationException).FullName );
				exp=null;
			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}

			con.Open();

			try
			{
				BeginCase("BeginTransaction - connection close");
				txn = con.BeginTransaction();
				Compare(txn == null,false );
			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}

			if (con.State == ConnectionState.Open) con.Close();

		}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:OracleTransaction_ctor.cs

示例2: ExecuteSqlTran

		/// <summary>
		/// 执行多条SQL语句,实现数据库事务。
		/// </summary>
		/// <param name="SQLStringList">多条SQL语句</param>		
		public static void ExecuteSqlTran(ArrayList SQLStringList)
		{
			using (OracleConnection conn = new OracleConnection(connectionString))
			{
				conn.Open();
				OracleCommand cmd = new OracleCommand();
				cmd.Connection=conn;				
				OracleTransaction tx=conn.BeginTransaction();			
				cmd.Transaction=tx;				
				try
				{   		
					for(int n=0;n<SQLStringList.Count;n++)
					{
						string strsql=SQLStringList[n].ToString();
						if (strsql.Trim().Length>1)
						{
							cmd.CommandText=strsql;
							cmd.ExecuteNonQuery();
						}
					}										
					tx.Commit();					
				}
				catch(System.Data.OracleClient.OracleException E)
				{		
					tx.Rollback();
					throw new Exception(E.Message);
				}
			}
		}
开发者ID:tianyaalone,项目名称:Water125,代码行数:33,代码来源:DbHelperOra.cs

示例3: MarkDeletedSpoolRecord

 public static void MarkDeletedSpoolRecord(string projectid, string spname, string drawing, string username)
 {
     OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//获得conn连接
     conn.Open();
     string queryString = "SP_MarkDeleteSpoolRecord";
     OracleTransaction trans = conn.BeginTransaction();
     OracleCommand cmd = new OracleCommand(queryString, conn);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.Add("projectid_in", OracleType.VarChar).Value = projectid;
     cmd.Parameters.Add("spname_in", OracleType.VarChar).Value = spname;
     cmd.Parameters.Add("drawing_in", OracleType.VarChar).Value = drawing;
     cmd.Parameters.Add("username_in", OracleType.VarChar).Value = username;
     cmd.Transaction = trans;
     try
     {
         cmd.ExecuteNonQuery();
         trans.Commit();
     }
     catch (OracleException ee)
     {
         trans.Rollback();
         MessageBox.Show(ee.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         conn.Close();
     }
 }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:28,代码来源:DelSpoolRecord.cs

示例4: UpdatePersonStatus

        public static void UpdatePersonStatus( string queryString, string project, string drawing, string spool, string person, DateTime dt, string frmtxt)
        {
            OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//获得conn连接
            conn.Open();
            //string queryString = "SP_UpdateBlankingStatus";
            OracleTransaction trans = conn.BeginTransaction();
            OracleCommand cmd = new OracleCommand(queryString, conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("project_in", OracleType.VarChar).Value = project;
            cmd.Parameters.Add("drawing_in", OracleType.VarChar).Value = drawing;
            cmd.Parameters.Add("spool_in", OracleType.VarChar).Value = spool;
            cmd.Parameters.Add("person_in", OracleType.VarChar).Value = person;
            cmd.Parameters.Add("datetime_in", OracleType.DateTime).Value = dt;
            cmd.Parameters.Add("frmtxt_in", OracleType.VarChar).Value = frmtxt;

            cmd.Transaction = trans;
            try
            {
                cmd.ExecuteNonQuery();
                trans.Commit();
            }
            catch (OracleException ee)
            {
                trans.Rollback();
                MessageBox.Show(ee.Message.ToString(), "错误", MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
        }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:32,代码来源:WorkShopStatusFlow.cs

示例5: ExecSql

        public int ExecSql(string[] sqls)
        {
            using (OracleConnection conn = new OracleConnection(ConnString))
            {
                OracleTransaction st;
                conn.Open();
                st = conn.BeginTransaction();
                try
                {
                    foreach (string sql in sqls)
                    {
                        OracleCommand scc = new OracleCommand(sql, conn);
                        scc.Transaction = st;
                        scc.ExecuteNonQuery();
                    }
                    st.Commit();
                    return 0;

                }
                catch
                {
                    st.Rollback();
                    return -1;
                }
            }
        }
开发者ID:romanu6891,项目名称:fivemen,代码行数:26,代码来源:DB.cs

示例6: AddHeatNo

        /// <summary>
        /// ������̺�
        /// </summary>
        /// <param name="heatno"></param>
        /// <param name="projectid"></param>
        /// <param name="spoolname"></param>
        /// <param name="materialname"></param>
        /// <param name="seqnum"></param>
        public static void AddHeatNo(string heatno, string projectid, string spoolname, string materialname, int seqnum)
        {
            OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//���conn����
            conn.Open();
            string queryString = "SP_AddHeatNo";
            OracleTransaction trans = conn.BeginTransaction();
            OracleCommand cmd = new OracleCommand(queryString, conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("heatno", OracleType.VarChar).Value = heatno;
            cmd.Parameters.Add("pid", OracleType.VarChar).Value = projectid;
            cmd.Parameters.Add("spname", OracleType.VarChar).Value = spoolname;
            cmd.Parameters.Add("material", OracleType.VarChar).Value = materialname;
            cmd.Parameters.Add("seqnumber", OracleType.Number).Value = seqnum;

            cmd.Transaction = trans;
            try
            {
                //conn.Open();
                cmd.ExecuteNonQuery();
                trans.Commit();
            }
            catch (OracleException ee)
            {
                trans.Rollback();
                MessageBox.Show(ee.Message.ToString(), "����", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
        }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:40,代码来源:DBConnection.cs

示例7: Save

        public static int Save(Applicant applicant)
        {
            int applicantId;

            using (OracleConnection oraDbConn =
                    new OracleConnection(
                        ConnStringFactory.getConnString(
                            ConnStringFactory.ConnStringType.Oracle))) {
                oraDbConn.Open();
                using (OracleTransaction oraTrans =
                        oraDbConn.BeginTransaction(IsolationLevel.ReadCommitted)) {
                    try {
                        applicantId = ApplicantDB.Save(applicant, oraDbConn, oraTrans);
                        foreach (Loan loan in applicant.Loans) {
                            loan.ApplicantId = applicantId;
                            LoanManager.Save(loan, oraDbConn, oraTrans);
                        }
                        applicant.Id = applicantId;

                        oraTrans.Commit();
                    }
                    catch (OracleException oraEx) {
                        oraTrans.Rollback();
                        throw oraEx;
                    }
                }
            }
            return applicantId;
        }
开发者ID:walbalooshi,项目名称:LoanApplication,代码行数:29,代码来源:ApplicantManager.cs

示例8: run

	public void run()
	{

		Exception exp = null;
		OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
		con.Open();
		OracleTransaction txn = con.BeginTransaction();
		OracleCommand cmd = new OracleCommand("Select * From Employees", con);

		try
		{
			BeginCase("check Transaction property - default");
			Compare(cmd.Transaction==null , true);
		} 
		catch(Exception ex){exp = ex;}
		finally{EndCase(exp); exp = null;}

		cmd.Transaction = txn;

		try
		{
			BeginCase("check Transaction property");
			Compare(cmd.Transaction , txn);
		} 
		catch(Exception ex){exp = ex;}
		finally{EndCase(exp); exp = null;}
		
		if (con.State == ConnectionState.Open) con.Close();

	}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:OracleCommand_Transaction.cs

示例9: run

		public void run()
		{
			OracleConnection con = null;
			OracleTransaction txn;
			Exception exp = null;
			try
			{
				BeginCase("OracleTransaction Rollback");

				//
				//prepare data
				base.PrepareDataForTesting(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);

				string Result = "";
				con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
				con.Open();
				txn = con.BeginTransaction();
				OracleCommand cmd = new OracleCommand("Update Employees Set LastName = 'StamLastName' Where EmployeeID = 100", con, txn);
				cmd.ExecuteNonQuery();
				txn.Rollback();

				//
				//
				cmd = new OracleCommand("Select LastName From Employees Where EmployeeID = 100", con);
				Result = cmd.ExecuteScalar().ToString();
				Compare(Result,"Last100" );
				this.Log(Result);

			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}

			if (con.State == ConnectionState.Open) con.Close();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:34,代码来源:OracleTransaction_Rollback.cs

示例10: GetDrawingWithBlock

        public static string GetDrawingWithBlock(string projectid, string block)
        {
            OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//获得conn连接
            conn.Open();
            string queryString = "SP_GetDrawingWithBlock";
            OracleTransaction trans = conn.BeginTransaction();
            OracleCommand cmd = new OracleCommand(queryString, conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("drawing_out", OracleType.VarChar,100);
            cmd.Parameters["drawing_out"].Direction = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add("projectid_in", OracleType.VarChar).Value = projectid;
            cmd.Parameters.Add("block_in", OracleType.VarChar).Value = block;

            cmd.Transaction = trans;
            try
            {
                cmd.ExecuteNonQuery();
                trans.Commit();
            }
            catch (OracleException ee)
            {
                trans.Rollback();
                MessageBox.Show(ee.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
            return cmd.Parameters["drawing_out"].Value.ToString();
        }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:31,代码来源:WorkShopClass.cs

示例11: AddTrayORClass

        public static void AddTrayORClass(string queryString, string project, string drawing, string spool,string trayorclass)
        {
            OracleConnection conn = new OracleConnection(DataAccess.OIDSConnStr);//获得conn连接
            conn.Open();
            OracleTransaction trans = conn.BeginTransaction();
            OracleCommand cmd = new OracleCommand(queryString, conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("project_in", OracleType.VarChar).Value = project;
            cmd.Parameters.Add("drawing_in", OracleType.VarChar).Value = drawing;
            cmd.Parameters.Add("spool_in", OracleType.VarChar).Value = spool;
            cmd.Parameters.Add("trayorclass_in", OracleType.VarChar).Value = trayorclass;
            cmd.Transaction = trans;
            try
            {
                cmd.ExecuteNonQuery();
                trans.Commit();
            }
            catch (OracleException ee)
            {
                trans.Rollback();
                MessageBox.Show(ee.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
        }
开发者ID:freudshow,项目名称:raffles-codes,代码行数:28,代码来源:WorkShopStatusFlow.cs

示例12: btnConfirm_Click

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (selection.SelectedCount == 0)
            {
                MessageBox.Show("没有选择单据");
            }
            else
            {

                using (OracleConnection connection = new OracleConnection(StrCon))
                {
                    connection.Open();
                    OracleCommand command = connection.CreateCommand();
                    OracleTransaction transaction;
                    transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                    command.Transaction = transaction;
                    try
                    {
                        for (int i = 0; i < selection.SelectedCount; ++i)
                        {
                            int RowIndex = selection.GetSelectedRowIndex(i);
                            int RowHandle = gridView1.GetRowHandle(RowIndex);
                            string strXSJSDID = gridView1.GetRowCellValue(RowHandle, colXSJSDID).ToString();
                            command.CommandText = "insert into Temp_Save_Id (tempid,id) Values (TEMP_SAVE_ID_SEQ.nextval,'" + strXSJSDID + "')";
                            command.ExecuteNonQuery();
                        }

                        selection.ClearSelection();
                        command.CommandType = CommandType.StoredProcedure;
                        command.CommandText = "JC_C_XSTSD_XD";
                        command.Parameters.Add("LS_XSTSDid", OracleType.VarChar).Value = this.btnConfirm.Tag.ToString();
                        command.Parameters.Add("DescErr", OracleType.VarChar, 255).Direction = ParameterDirection.Output;
                        command.Parameters.Add("Message", OracleType.VarChar, 255).Direction = ParameterDirection.Output;

                        command.ExecuteNonQuery();
                        transaction.Commit();
                        string mess = command.Parameters["Message"].Value.ToString();
                        string alarm = command.Parameters["DescErr"].Value.ToString();
                        MessageBox.Show(mess + alarm);

                    }
                    catch (OracleException ex)
                    {
                        transaction.Rollback();
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        connection.Close();
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                }

            }
        }
开发者ID:radtek,项目名称:wxcm-project,代码行数:57,代码来源:FrmClientTuoShouJCSelectCase.cs

示例13: get_cust_id_by_acct_id

        public void get_cust_id_by_acct_id(int acct_id, out int p_cust_id, out int rc, out string msg)
        {
            rc = -1;
            msg = null;
            p_cust_id = -1;

            string connStr = getConnectionString();

            try
            {

                log.Info(string.Format("get_cust_id_by_acct_id acct_id={0}", acct_id));

                using (OracleConnection objConn = new OracleConnection(connStr))
                {
                    objConn.Open();
                    OracleTransaction transaction;
                    transaction = objConn.BeginTransaction();

                    OracleCommand objCmd = new OracleCommand(schemaPrefixSap + "crmws_functions.get_cust_id_by_acct_id", objConn);
                    objCmd.CommandType = CommandType.StoredProcedure;

                    try
                    {
                        objCmd.Transaction = transaction;
                        objCmd.Parameters.Clear();
                        objCmd.Parameters.Add("p_acct_id", OracleType.Number).Value = dbNlv(acct_id);
                        objCmd.Parameters.Add("p_cust_id", OracleType.Number).Direction = ParameterDirection.Output;
                        objCmd.Parameters.Add("p_rc", OracleType.Number).Direction = ParameterDirection.Output;
                        objCmd.Parameters.Add("p_msg", OracleType.VarChar, 2048).Direction = ParameterDirection.Output;
                        objCmd.ExecuteNonQuery();

                        rc = int.Parse(objCmd.Parameters["p_rc"].Value.ToString());
                        msg = objCmd.Parameters["p_msg"].Value.ToString();
                        p_cust_id = int.Parse(objCmd.Parameters["p_cust_id"].Value.ToString());

                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                        rc = -3;
                        log.Error("get_cust_id_by_acct_id", e);
                    }
                    finally
                    {
                        objConn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("get_cust_id_by_acct_id", e);
                rc = -1;
            }
        }
开发者ID:jTyma,项目名称:_RepositoryNET,代码行数:56,代码来源:SAP2BOSS.asmx.cs

示例14: GetAccountByCert

        public void GetAccountByCert(
            string CertValue, string CertType,
            out string AcctId,
            out int rc, out string msg
        )
        {
            rc = -1;
            msg = null;
            AcctId = "";

            try
            {
                log.Info(string.Format(
                    "GetAccountByCert CertValue={0} CertType={1}", CertValue, CertType));

                using (OracleConnection objConn = new OracleConnection(connStr))
                {
                    objConn.Open();
                    OracleTransaction transaction;
                    transaction = objConn.BeginTransaction();

                    OracleCommand objCmd = new OracleCommand(schemaPrefixSap + "crmws_functions.get_account_by_cert", objConn);

                    objCmd.CommandType = CommandType.StoredProcedure;

                    objCmd.Transaction = transaction;
                    objCmd.Parameters.Clear();
                    objCmd.Parameters.Add("p_cert_value", OracleType.VarChar).Value = dbNlv(CertValue);
                    objCmd.Parameters.Add("p_cert_type", OracleType.VarChar).Value = dbNlv(CertType);

                    objCmd.Parameters.Add("p_acct_id", OracleType.VarChar, 200).Direction = ParameterDirection.Output;

                    objCmd.Parameters.Add("p_rc", OracleType.Number).Direction = ParameterDirection.Output;
                    objCmd.Parameters.Add("p_msg", OracleType.VarChar, 500).Direction = ParameterDirection.Output;

                    objCmd.ExecuteNonQuery();

                    rc = int.Parse(objCmd.Parameters["p_rc"].Value.ToString());
                    msg = objCmd.Parameters["p_msg"].Value.ToString();
                    AcctId = objCmd.Parameters["p_acct_id"].Value.ToString();
                    transaction.Commit();
                    objConn.Close();
                }

            }
            catch (Exception e)
            {
                rc = -1;
                msg = e.Message;
                log.Error("GetAccountByCert exception", e);
            }

            log.Info(string.Format(
                "GetAccountByCert finished: rc={0}, msg={1}, AcctId={2}",
                rc, msg, AcctId));
        }
开发者ID:jTyma,项目名称:_RepositoryNET,代码行数:56,代码来源:GSMResourceInventory.asmx.cs

示例15: add_Customer

        //Creating variables using parameters and assigning them to textboxes to insert into the customer table
        public void add_Customer(Customer_Entity_Class customer)
        {
            /*
             * Creating a connection  to connect to the database calling Orc class that returns the connection string
             */
                OracleConnection connection = new OracleConnection(OrcConnection.connection());

                OracleCommand cmd = new OracleCommand();

                try
                {
                    connection.Open();
                    OracleTransaction transaction = connection.BeginTransaction();
                    cmd.Transaction = transaction;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = " INSERT INTO Customers Values(customer_seq.NEXTVAL,:forename,:surname,:address,:town,:county,:phoneNo,:custType)";

                    OracleParameter forename = new OracleParameter(":forename", OracleType.VarChar);
                    forename.Value = customer.Forename;
                    cmd.Parameters.Add(forename);

                    OracleParameter surname = new OracleParameter(":surname", OracleType.VarChar);
                    surname.Value = customer.Surname;
                    cmd.Parameters.Add(surname);

                    OracleParameter address = new OracleParameter(":address", OracleType.VarChar);
                    address.Value = customer.Address;
                    cmd.Parameters.Add(address);

                    OracleParameter town = new OracleParameter(":town", OracleType.VarChar);
                    town.Value = customer.Town;
                    cmd.Parameters.Add(town);

                    OracleParameter county = new OracleParameter(":county", OracleType.VarChar);
                    county.Value = customer.County;
                    cmd.Parameters.Add(county);

                    OracleParameter phone_no = new OracleParameter(":phoneNo", OracleType.Number);
                    phone_no.Value = customer.Phone_No;
                    cmd.Parameters.Add(phone_no);

                    OracleParameter cust_Type = new OracleParameter(":custType", OracleType.VarChar);
                    cust_Type.Value = customer.Cust_Type;
                    cmd.Parameters.Add(cust_Type);

                    cmd.Connection = connection;
                    cmd.ExecuteNonQuery();
                    transaction.Commit();
                    connection.Close();
                    MessageBox.Show("Insert complete successfully");
                }
                catch (Exception)
                {
                    MessageBox.Show("Insert did not complete Succesfully", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
        }
开发者ID:pafennell,项目名称:SoftwareEngineering,代码行数:57,代码来源:Customer_Access.cs


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