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


C# SqlClient.SqlTransaction类代码示例

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


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

示例1: Add

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DataRow dr, SqlTransaction trans)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO hrCompanyShopInfo(");
            strSql.Append("MainID,sShopID,sShopCName,sShopEName,sRemark,sUserID)");
            strSql.Append(" VALUES (");
            strSql.Append("@MainID,@sShopID,@sShopCName,@sShopEName,@sRemark,@sUserID)");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@MainID", SqlDbType.Int,4),
                    new SqlParameter("@sShopID", SqlDbType.VarChar,30),
                    new SqlParameter("@sShopCName", SqlDbType.VarChar,50),
                    new SqlParameter("@sShopEName", SqlDbType.VarChar,50),
                    new SqlParameter("@sRemark", SqlDbType.VarChar,200),
                    new SqlParameter("@sUserID", SqlDbType.VarChar,30)};
            parameters[0].Value = dr["MainID"];
            parameters[1].Value = dr["sShopID"];
            parameters[2].Value = dr["sShopCName"];
            parameters[3].Value = dr["sShopEName"];
            parameters[4].Value = dr["sRemark"];
            parameters[5].Value = dr["sUserID"];

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), trans, parameters);
            if (obj == null)
            {
                return -1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
开发者ID:ViniciusConsultor,项目名称:belself-wang,代码行数:35,代码来源:hrCompanyShopInfoDAL.cs

示例2: TitleLanguageDeleteAuto

 /// <summary>
 /// Delete values from TitleLanguage by primary key(s).
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="titleLanguageID"></param>
 /// <returns>true if successful otherwise false.</returns>
 public bool TitleLanguageDeleteAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     int titleLanguageID)
 {
     return TitleLanguageDeleteAuto( sqlConnection, sqlTransaction, "BHL", titleLanguageID );
 }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:14,代码来源:TitleLanguageDAL.Auto.cs

示例3: ItemDeleteAuto

 /// <summary>
 /// Delete values from Item by primary key(s).
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="itemID"></param>
 /// <returns>true if successful otherwise false.</returns>
 public bool ItemDeleteAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     int itemID)
 {
     return ItemDeleteAuto( sqlConnection, sqlTransaction, "BHL", itemID );
 }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:14,代码来源:ItemDAL.Auto.cs

示例4: Add

 public void Add(SqlTransaction transaction)
 {
     _orderInsertDataParameters = new OrderInsertDataParameters(Orders);
     DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName);
     object id = dbHelper.RunScalar(transaction, _orderInsertDataParameters.Parameters);
     Orders.OrderId = int.Parse(id.ToString());
 }
开发者ID:simonbegg,项目名称:LiveFreeRange,代码行数:7,代码来源:OrderInsertData.cs

示例5: GetInsertCommand

 /// <summary>
 /// Get insert cmd of GENERAL_AUT_USERROLE table
 /// </summary>
 /// <param name="con"></param>
 /// <param name="trans"></param>
 /// <returns></returns>
 /// <remarks>
 /// Author:			PhatLT. FPTSS.
 /// Created date:	14/02/2011
 /// </remarks>
 public SqlCommand GetInsertCommand(SqlConnection con, SqlTransaction trans)
 {
     SqlCommand cmd = new SqlCommand("INSERT INTO GENERAL_AUT_USERROLE(UROLE_ID, ROLE_NAME) VALUES(@UROLE_ID, @ROLE_NAME)", con, trans);
     cmd.Parameters.Add("@UROLE_ID", SqlDbType.VarChar, 14, "UROLE_ID");
     cmd.Parameters.Add("@ROLE_NAME", SqlDbType.VarChar, 255, "ROLE_NAME");
     return cmd;
 }
开发者ID:hieu292,项目名称:project-dms,代码行数:17,代码来源:clsUserRoleDAO.cs

示例6: PDFStatusDeleteAuto

 /// <summary>
 /// Delete values from PDFStatus by primary key(s).
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="pdfStatusID"></param>
 /// <returns>true if successful otherwise false.</returns>
 public bool PDFStatusDeleteAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     int pdfStatusID)
 {
     return PDFStatusDeleteAuto( sqlConnection, sqlTransaction, "BHL", pdfStatusID );
 }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:14,代码来源:PDFStatusDAL.Auto.cs

示例7: Update_ControlPresupuestal

        public bool Update_ControlPresupuestal(ControlPresupuestal_VO pControlPresupuestal, SqlTransaction TransControlPresupuestal)
        {
            bool b_ControlPresupuestal;
            try
            {

                SqlCommand cmdComand = new SqlCommand("USP_U_SICOP_CONTROLPRESUPUESTAL");
                cmdComand.CommandType = System.Data.CommandType.StoredProcedure;
                cmdComand.Connection = TransControlPresupuestal.Connection;
                cmdComand.Transaction = TransControlPresupuestal;
                cmdComand.Parameters.Clear();
                cmdComand.Parameters.AddWithValue("@CPRE_INT_IDCONTROLPRESUPUESTAL", pControlPresupuestal.CPRE_INT_IDCONTROLPRESUPUESTAL);
                cmdComand.Parameters.AddWithValue("@EGAS_VCH_IDESPECIFICADEGASTO", pControlPresupuestal.EGAS_VCH_IDESPECIFICADEGASTO);
                cmdComand.Parameters.AddWithValue("@DOCU_INT_IDDOCUMENTO", pControlPresupuestal.DOCU_INT_IDDOCUMENTO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_NRODOCUMENTO", pControlPresupuestal.CPRE_VCH_NRODOCUMENTO);
                cmdComand.Parameters.AddWithValue("@CPRE_DAT_FECHAINGRESO", pControlPresupuestal.CPRE_DAT_FECHAINGRESO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_NROCOMPROBANTEPAGO", pControlPresupuestal.CPRE_VCH_NROCOMPROBANTEPAGO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_NROSIAF", pControlPresupuestal.CPRE_VCH_NROSIAF);
                cmdComand.Parameters.AddWithValue("@CPRE_DAT_FECHAGIRO", pControlPresupuestal.CPRE_DAT_FECHAGIRO);
                cmdComand.Parameters.AddWithValue("@CPRE_DAT_FECHAPAGO", pControlPresupuestal.CPRE_DAT_FECHAPAGO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_CONCEPTOESPECIFICADEGASTO", pControlPresupuestal.CPRE_VCH_CONCEPTOESPECIFICADEGASTO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_DETALLEESPECIFICADEGASTO", pControlPresupuestal.CPRE_VCH_DETALLEESPECIFICADEGASTO);
                cmdComand.Parameters.AddWithValue("@CPRE_VCH_PARTIDACONTABLE", pControlPresupuestal.CPRE_VCH_PARTIDACONTABLE);
                b_ControlPresupuestal = cmdComand.ExecuteNonQuery() > 0;

            }
            catch (Exception e)
            {
                if (e.Source != null)
                    Console.WriteLine("IOException source: {0}", e.Source);
                throw;
            }
            return b_ControlPresupuestal;
        }
开发者ID:tchambil,项目名称:presupuesto,代码行数:34,代码来源:ControlPresupuestal_DAL.cs

示例8: ExcuteDataTableByTextWithTrans

        public static DataTable ExcuteDataTableByTextWithTrans(SqlConnection connection, SqlTransaction tran, string sqlText, IDataParameter[] paramers)
        {
            DataTable dt = new DataTable("");
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            SqlCommand cmd = new SqlCommand(sqlText, connection, tran);
            cmd.CommandTimeout = 300;
            cmd.CommandType = CommandType.Text;
            if (null != paramers)
            {
                foreach (SqlParameter param in paramers)
                {
                    cmd.Parameters.Add(param);
                }
            }

            ////Add parameter to receive return value of stored procedure
            //SqlParameter pr = new SqlParameter("ReturnValue", SqlDbType.Int);
            //pr.Direction = ParameterDirection.ReturnValue;
            //cmd.Parameters.Add(pr);

            SqlDataAdapter ada = new SqlDataAdapter(cmd);
            ada.Fill(dt);

            return dt;
            //return pr.Value;
        }
开发者ID:SiberianMark,项目名称:WebServiceDocNet,代码行数:30,代码来源:SqlHelper.cs

示例9: Insert_Callstack

        public static bool Insert_Callstack(SqlConnection conn, ref SqlTransaction tran, int project_uid, byte[] signature, out int callstack_uid)
        {
            callstack_uid = 0;

            try
            {
                SqlCommand cmd1 = new SqlCommand("usp_insert_callstack", conn, tran);
                cmd1.CommandType = CommandType.StoredProcedure;

                SqlParameter returned = cmd1.CreateParameter();
                returned.Direction = ParameterDirection.ReturnValue;

                cmd1.Parameters.Add(returned);
                cmd1.Parameters.AddWithValue("@project_uid", project_uid);
                cmd1.Parameters.AddWithValue("@signature", signature);

                cmd1.ExecuteNonQuery();

                callstack_uid = (int)returned.Value;
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                return false;
            }

            return true;
        }
开发者ID:NtreevSoft,项目名称:Crashweb,代码行数:28,代码来源:DB.cs

示例10: CreateAddProductCommand

        public SqlCommand CreateAddProductCommand(SqlConnection conn, SqlTransaction transaction)
        {
            var cmd = new SqlCommand(_sql, conn, transaction);
            CreateParameters(cmd);

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

示例11: ExecuteScalarProcedure

 internal static object ExecuteScalarProcedure(SqlConnection connection, SqlTransaction transaction, string procName, Dictionary<string, object> parameters)
 {
     using (var command = PrepareCommandForProcedure(connection, transaction, procName, parameters))
     {
         return command.ExecuteScalar();
     }
 }
开发者ID:dnovatchev,项目名称:ShortenUrlService,代码行数:7,代码来源:Db.cs

示例12: ExecuteNonQueryProcedure

 internal static void ExecuteNonQueryProcedure(SqlConnection connection, SqlTransaction transaction, string procName, Dictionary<string, object> parameters)
 {
     using (var command = PrepareCommandForProcedure(connection, transaction, procName, parameters))
     {
         command.ExecuteNonQuery();
     }
 }
开发者ID:dnovatchev,项目名称:ShortenUrlService,代码行数:7,代码来源:Db.cs

示例13: DeleteCheckedItems

    //-------------------------------------------------------------------------------------------
    public void DeleteCheckedItems(SqlTransaction transaction, Control parent)
    {
        //foreach (Control control in parent.Controls)
          //{
          //     if (control.GetType() == typeof(CheckBox))
          //     {
          //          CheckBox item = (CheckBox)control;
          //          if (item.Checked)
          //          {
          //               Guid itemId = new Guid(item.Attributes["datakey"]);
          //               DataRowLookup reverseLookup = DatabaseHelper.Session.Get<DataRowLookup>(itemId);
          //               if (reverseLookup != null)
          //               {
          //                    SqlCommand command = new SqlCommand("delete from " + reverseLookup.TableName + " where [email protected]", wvvrdb.MSSQLDB);
          //                    command.Parameters.AddWithValue("Id", reverseLookup.RowId);
          //                    command.Transaction = transaction;
          //                    command.ExecuteNonQuery();
          //               }

          //               string sql = "delete from system_datalinks where ([email protected] and [email protected]) ";
          //               sql += "or ([email protected] and [email protected])";
          //               SqlCommand dataLinks = new SqlCommand(sql, wvvrdb.MSSQLDB);
          //               dataLinks.Parameters.AddWithValue("Object1", itemId);
          //               dataLinks.Parameters.AddWithValue("Object2", new Guid(Request["id"]));
          //               dataLinks.Transaction = transaction;
          //               dataLinks.ExecuteNonQuery();
          //          }
          //     }
          //     if (control.HasControls())
          //     {
          //          DeleteCheckedItems(transaction, control);
          //     }
          //}
    }
开发者ID:weavver,项目名称:weavver,代码行数:35,代码来源:DeleteObject.aspx.cs

示例14: Add

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DataRow dr, SqlTransaction trans)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO sysMenuParam(");
            strSql.Append("MenuID,sParamName,sParamValue,sUserID)");
            strSql.Append(" VALUES (");
            strSql.Append("@MenuID,@sParamName,@sParamValue,@sUserID)");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@MenuID", SqlDbType.Int,4),
                    new SqlParameter("@sParamName", SqlDbType.VarChar,50),
                    new SqlParameter("@sParamValue", SqlDbType.VarChar,50),
                    new SqlParameter("@sUserID", SqlDbType.VarChar,30)};
            parameters[0].Value = dr["MenuID"];
            parameters[1].Value = dr["sParamName"];
            parameters[2].Value = dr["sParamValue"];
            parameters[3].Value = dr["sUserID"];

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), trans, parameters);
            if (obj == null)
            {
                return -1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
开发者ID:ViniciusConsultor,项目名称:belself-wang,代码行数:31,代码来源:sysMenuParamDAL.cs

示例15: MarcControlDeleteAuto

 /// <summary>
 /// Delete values from MarcControl by primary key(s).
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="marcControlID"></param>
 /// <returns>true if successful otherwise false.</returns>
 public bool MarcControlDeleteAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     int marcControlID)
 {
     return MarcControlDeleteAuto( sqlConnection, sqlTransaction, "BHL", marcControlID );
 }
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:14,代码来源:MarcControlDAL.Auto.cs


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