• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SqlCeTransaction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateAddProductCommand

        public SqlCeCommand CreateAddProductCommand(SqlCeConnection conn, SqlCeTransaction transaction)
        {
            var cmd = new SqlCeCommand(_sql, conn, transaction);
            CreateParameters(cmd);

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


示例2: DeleteAllFileNames

 public static void DeleteAllFileNames(SqlCeTransaction transaction, SqlCeConnection conn)
 {
     SqlCeCommand command = new SqlCeCommand(Folder_Names_SQL.commandDeleteAllFolderNames, conn);
     command.Transaction = transaction;
     command.Connection = conn;
     command.ExecuteNonQuery();
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:7,代码来源:Folder_Names.cs


示例3: DeletAllRespectiveCapturePointsForTextConversion

 public static void DeletAllRespectiveCapturePointsForTextConversion(int captureEventId, SqlCeConnection conn, SqlCeTransaction transaction)
 {
     //pointRecId
     int value = 0;
     SqlCeCommand command = new SqlCeCommand(Rec_CapturePoints_TextConv_SQL.commandRemoveAllCapturePointsByRecIdTextConv, conn);
     command.Transaction = transaction;
     command.Parameters.Add("@pointRecId", captureEventId);
     value = Convert.ToInt32(command.ExecuteNonQuery());
 }
开发者ID:mzkabbani,项目名称:XMLParser,代码行数:9,代码来源:Rec_CapturePoints_TextConv.cs


示例4: BeginTransaction

        /// <summary>
        ///     Starts a Transaction using the Connection instance
        /// </summary>
        /// <returns>
        ///     The <see cref="SqlCeTransaction" />.
        /// </returns>
        public SqlCeTransaction BeginTransaction()
        {
            if (this.transaction != null)
            {
                throw new InvalidOperationException(
                    "A transaction has already been started. Only one transaction is allowed");
            }

            this.transaction = EntityBase.Connection.BeginTransaction();
            this.UsersDB.Transaction = this.transaction;
            return this.transaction;
        }
开发者ID:novaksam,项目名称:CIS499_C-_IM_Package,代码行数:18,代码来源:DataRepository.cs


示例5: SaveReplacementEventForTextConversion

 public static void SaveReplacementEventForTextConversion(ReplacementEvent replacementEvent, SqlCeConnection conn, SqlCeTransaction transaction)
 {
     SqlCeCommand command = new SqlCeCommand(Advanced_Replacements_TextConv_SQL.commandUpdateReplacementByIdTextConv, conn);
     command.Transaction = transaction;
     command.Parameters.Add("@name", replacementEvent.name);
     command.Parameters.Add("@description", replacementEvent.description);
     command.Parameters.Add("@value", replacementEvent.Value);
     command.Parameters.Add("@typeId", replacementEvent.typeId);
     command.Parameters.Add("@capturePointId", replacementEvent.capturePointId);
     command.Parameters.Add("@userId", replacementEvent.userId);
     command.Parameters.Add("@usageCount", replacementEvent.usageCount);
     command.Parameters.Add("@id", replacementEvent.id);
     command.ExecuteNonQuery();
 }
开发者ID:mzkabbani,项目名称:XMLParser,代码行数:14,代码来源:Advanced_Replacements_TextConv.cs


示例6: InsertFolderName

 public static void InsertFolderName(int index, string folderName, object parentId, string generatedID, SqlCeTransaction transaction, SqlCeConnection conn)
 {
     try {
         SqlCeCommand command = new SqlCeCommand(Folder_Names_SQL.commandInsertFolderName, conn);
         command.Parameters.Add("@id", index);
         command.Parameters.Add("@folderName", folderName);
         command.Parameters.Add("@parentId", parentId);
         command.Parameters.Add("@generatedID", generatedID);
         command.Transaction = transaction;
         command.Connection = conn;
         command.ExecuteNonQuery();
     } catch (Exception ex) {
         CommonUtils.LogError(ex.Message, ex);
     }
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:15,代码来源:Folder_Names.cs


示例7: InsertUpdatedFileNames

 public static void InsertUpdatedFileNames(List<TreeNode> treeNodes, SqlCeTransaction transaction, SqlCeConnection conn)
 {
     try {
         for (int i = 0; i < treeNodes.Count; i++) {
             int parentId = treeNodes[i].Parent == null ? -1 : treeNodes.IndexOf(treeNodes[i].Parent);
             if (parentId != -1) {
                 InsertFolderName(i, treeNodes[i].Text, parentId, treeNodes[i].Tag.ToString(), transaction, conn);
             } else {
                 InsertFolderName(i, treeNodes[i].Text, DBNull.Value, treeNodes[i].Tag.ToString(), transaction, conn);
             }
         }
     } catch (Exception ex) {
         CommonUtils.LogError(ex.Message,ex);
     }
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:15,代码来源:Folder_Names.cs


示例8: ExecuteNonQuery

    /// <summary>
    ///     A SqlCeConnection extension method that executes the non query operation.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="cmdText">The command text.</param>
    /// <param name="parameters">Options for controlling the operation.</param>
    /// <param name="commandType">Type of the command.</param>
    /// <param name="transaction">The transaction.</param>
    public static void ExecuteNonQuery(this SqlCeConnection @this, string cmdText, SqlCeParameter[] parameters, CommandType commandType, SqlCeTransaction transaction)
    {
        using (SqlCeCommand command = @this.CreateCommand())
        {
            command.CommandText = cmdText;
            command.CommandType = commandType;
            command.Transaction = transaction;

            if (parameters != null)
            {
                command.Parameters.AddRange(parameters);
            }

            command.ExecuteNonQuery();
        }
    }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:24,代码来源:SqlCeConnection.ExecuteNonQuery.cs


示例9: SqlCeExecuteReader

    /// <summary>
    ///     A SqlCeConnection extension method that executes the reader operation.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="cmdText">The command text.</param>
    /// <param name="parameters">Options for controlling the operation.</param>
    /// <param name="commandType">Type of the command.</param>
    /// <param name="transaction">The transaction.</param>
    /// <returns>A SqlCeDataReader.</returns>
    public static SqlCeDataReader SqlCeExecuteReader(this SqlCeConnection @this, string cmdText, SqlCeParameter[] parameters, CommandType commandType, SqlCeTransaction transaction)
    {
        using (SqlCeCommand command = @this.CreateCommand())
        {
            command.CommandText = cmdText;
            command.CommandType = commandType;
            command.Transaction = transaction;

            if (parameters != null)
            {
                command.Parameters.AddRange(parameters);
            }

            return command.ExecuteReader();
        }
    }
开发者ID:huoxudong125,项目名称:Z.ExtensionMethods,代码行数:25,代码来源:SqlCeConnection.SqlCeExecuteReader.cs


示例10: OpenConnection

 private void OpenConnection(SqlCeConnection aSqlCeConnection, SqlCeTransaction aSqlCeTransaction)
 {
     using (SqlCeCommand sqlCommand = new SqlCeCommand("SELECT s.Id_Session, s.Session, s.[DateTime] FROM Session AS s", aSqlCeConnection, aSqlCeTransaction))
     {
         sqlCommand.CommandType = CommandType.Text;
         using (SqlCeDataReader rdr = sqlCommand.ExecuteReader())
         {
             if (rdr.Read())
             {
                 FId_Session = (Int32)rdr["Id_Session"];
                 FSession = (Guid)rdr["Session"];
                 FDateTime = (DateTime)rdr["DateTime"];
             }
         }
     }
 }
开发者ID:BeL1kOFF,项目名称:SHATE,代码行数:16,代码来源:ObjectSession.cs


示例11: InserNewCategory

 public static int InserNewCategory(ComparisonCategory comparisonCategory, SqlCeTransaction transaction, SqlCeConnection conn)
 {
     SqlCeCommand command = new SqlCeCommand(Env_Comparison_Categories_SQL.commandInsertNewEnvComparisonCategory, conn);
        command.Transaction = transaction;
        command.Parameters.Add("@id", comparisonCategory.categoryId);
        command.Parameters.Add("@name", comparisonCategory.categoryName);
        command.Parameters.Add("@description", comparisonCategory.categoryDescription);
        command.Parameters.Add("@path", comparisonCategory.categoryPath);
        if (comparisonCategory.categoryParentId == -1) {
        //DBNull.Value
        command.Parameters.Add("@parentId", DBNull.Value);
        } else {
        command.Parameters.Add("@parentId", comparisonCategory.categoryParentId);
        }
        int numberAffectedRows = Convert.ToInt32(command.ExecuteNonQuery());
        return numberAffectedRows;
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:17,代码来源:Env_Comparison_Categories.cs


示例12: Excluir

        public int Excluir(SqlCeTransaction bdTrans)
        {
            //string sqlUpdateEstoque = "";
            //Código temporariamente comentado por estar com erro 19/03/2009

            //            foreach (GradeItem gi in LstGradeItem)
            //            {
            //                //Recupera a quantidade do estoque
            //                string sqlPedidoOriginalQuantidade = @"
            //                select
            //                     quantidade
            //                from
            //                     item_pedido_grade
            //                where
            //                     id_pedido=" + Globals.Pedido.Id + " and id_produto=" + Produto.Id +
            //                         @" and id_grade = " + Produto.IdGrade.V +
            //                         @" and id_item_grade = " + gi.IdItemGrade +
            //                         @" and id_atributo = " + gi.IdAtributo +
            //                         @" and id_item_atributo = " + gi.IdItemAtributo;

            //                IntN quantidadeOriginal = Globals.Bd.IntN(sqlPedidoOriginalQuantidade, bdTrans);
            //                if (quantidadeOriginal.Iniciada)
            //                {
            //                    sqlUpdateEstoque = @"
            //                    update
            //                        saldo_grade
            //                    set
            //                        estoque=estoque + " + quantidadeOriginal.V + @"
            //                    where
            //                        id_produto=" + Produto.Id +
            //                                @" and id_grade = " + Produto.IdGrade.V +
            //                                @" and id_item_grade = " + gi.IdItemGrade +
            //                                @" and id_atributo = " + gi.IdAtributo +
            //                                @" and id_item_atributo = " + gi.IdItemAtributo;
            //                    Globals.Bd.ExecuteNonQuery(sqlUpdateEstoque, bdTrans);
            //                }
            //            }

            int rf;
            string sqlDeleteItemGrade = @"
            delete from
                item_pedido_grade
            where id_produto=" + Produto.Id + " and id_pedido='" + Produto.Pedido.Id + "'";
            rf = D.Bd.ExecuteNonQuery(sqlDeleteItemGrade, bdTrans);
            return rf;
        }
开发者ID:evandrojr,项目名称:NeoPocket,代码行数:46,代码来源:Grade.cs


示例13: SetPrimaryKey

        public static void SetPrimaryKey(SqlCeTransaction trans, SqlCeRowUpdatedEventArgs e)
        {
            // If this is an INSERT operation...
            if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
            {
                System.Data.DataColumn[] pk = e.Row.Table.PrimaryKey;
                // and a primary key PK column exists...
                if (pk != null && pk.Length == 1)
                {
                    //Set up the post-update query to fetch new @@Identity
                    SqlCeCommand cmdGetIdentity = new SqlCeCommand("SELECT @@IDENTITY", (SqlCeConnection)trans.Connection, trans);

                    //Execute the command and set the result identity value to the PK
                    e.Row[pk[0]] = Convert.ToInt32(cmdGetIdentity.ExecuteScalar());
                    e.Row.AcceptChanges();
                }
            }
        }
开发者ID:kubinform,项目名称:TEST_MD,代码行数:18,代码来源:SQLCEIDHelper.cs


示例14: ExecuteExpandoObjects

    /// <summary>
    ///     Enumerates execute expando objects in this collection.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="cmdText">The command text.</param>
    /// <param name="parameters">Options for controlling the operation.</param>
    /// <param name="commandType">Type of the command.</param>
    /// <param name="transaction">The transaction.</param>
    /// <returns>
    ///     An enumerator that allows foreach to be used to process execute expando objects in this collection.
    /// </returns>
    public static IEnumerable<dynamic> ExecuteExpandoObjects(this SqlCeConnection @this, string cmdText, SqlCeParameter[] parameters, CommandType commandType, SqlCeTransaction transaction)
    {
        using (SqlCeCommand command = @this.CreateCommand())
        {
            command.CommandText = cmdText;
            command.CommandType = commandType;
            command.Transaction = transaction;

            if (parameters != null)
            {
                command.Parameters.AddRange(parameters);
            }

            using (IDataReader reader = command.ExecuteReader())
            {
                return reader.ToExpandoObjects();
            }
        }
    }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:30,代码来源:SqlCeConnection.ExecuteExpandoObjects.cs


示例15: Save

		public override bool Save(SqlCeTransaction tr)
		{
			bool res = true;

			try
			{
				//save this
				switch (Status)
				{
					case Status.Added:
						if (string.IsNullOrWhiteSpace(Id))
							this.Id = Generator.GenerateID(CConstants.COLL);
						res = AddValue(this, tr);
						Status = Common.Interfaces.Status.Normal;
						break;
					case Status.Normal:
						break;
					case Status.Updated:
						res = UpdateValue(this);
						Status = Common.Interfaces.Status.Normal;
						break;
					case Status.Deleted:
						res = DeleteValue(this.Id);
						break;
					default:
						Status = Common.Interfaces.Status.Normal;
						break;
				}
			}
			catch (Exception ex)
			{
				res = false;
			}

			if (res)
			{
				Status = Common.Interfaces.Status.Normal;
			}

			return res;
		}
开发者ID:justdude,项目名称:DbExport,代码行数:41,代码来源:CColumn.cs


示例16: ExecuteDataSet

    /// <summary>
    ///     A SqlCeConnection extension method that executes the data set operation.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="cmdText">The command text.</param>
    /// <param name="parameters">Options for controlling the operation.</param>
    /// <param name="commandType">Type of the command.</param>
    /// <param name="transaction">The transaction.</param>
    /// <returns>A DataSet.</returns>
    public static DataSet ExecuteDataSet(this SqlCeConnection @this, string cmdText, SqlCeParameter[] parameters, CommandType commandType, SqlCeTransaction transaction)
    {
        using (SqlCeCommand command = @this.CreateCommand())
        {
            command.CommandText = cmdText;
            command.CommandType = commandType;
            command.Transaction = transaction;

            if (parameters != null)
            {
                command.Parameters.AddRange(parameters);
            }

            var ds = new DataSet();
            using (var dataAdapter = new SqlCeDataAdapter(command))
            {
                dataAdapter.Fill(ds);
            }

            return ds;
        }
    }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:31,代码来源:SqlCeConnection.ExecuteDataSet.cs


示例17: InsertCapturePointsAsTransactionForTextConversion

        public static int InsertCapturePointsAsTransactionForTextConversion(int RecommendationId, List<CustomTreeNode> customNodesList, SqlCeConnection conn, SqlCeTransaction transaction)
        {
            int returnCode = -1;
            List<int> capturePointsIds = new List<int>();
            for (int i = 0; i < customNodesList.Count; i++) {
                SqlCeCommand command = new SqlCeCommand(Rec_CapturePoints_TextConv_SQL.commandInsertCapturePointTextConv, conn);
                command.Transaction = transaction;
                //@pointText, @pointUsedAttributes, @pointParentNode, @pointUsedAttribValues, @pointRecId
                command.Parameters.Add("@pointText", customNodesList[i].Text);
                command.Parameters.Add("@pointUsedAttributes", BackEndUtils.GetUsedAttributes(customNodesList[i].customizedAttributeCollection));
                command.Parameters.Add("@pointParentNode", (customNodesList[i].Parent == null ? "" : customNodesList[i].Parent.Text));
                command.Parameters.Add("@pointUsedAttribValues", BackEndUtils.GetUsedAttributesValues(customNodesList[i].customizedAttributeCollection));
                command.Parameters.Add("@pointRecId", RecommendationId);
                command.Parameters.Add("@Level", customNodesList[i].Level);
                command.Parameters.Add("@ItemIndex", customNodesList[i].Index);
                command.Parameters.Add("@parentLevel", customNodesList[i].Parent == null ? -1 : customNodesList[i].Parent.Level);
                command.Parameters.Add("@parentIndex", customNodesList[i].Parent == null ? -1 : customNodesList[i].Parent.Index);

                returnCode = Convert.ToInt32(command.ExecuteNonQuery());
                SqlCeCommand commandMaxId = new SqlCeCommand(Rec_CapturePoints_TextConv_SQL.commandMaxCapturePointIdTextConv, conn);
                capturePointsIds.Add(Convert.ToInt32(commandMaxId.ExecuteScalar()));
            }
            return returnCode;
        }
开发者ID:mzkabbani,项目名称:XMLParser,代码行数:24,代码来源:Rec_CapturePoints_TextConv.cs


示例18: InsertUpdatedCategories

 private static void InsertUpdatedCategories(List<ComparisonCategoryTreeNode> treeNodes, SqlCeTransaction transaction, SqlCeConnection conn)
 {
     for (int i = 0; i < treeNodes.Count; i++) {
        int parentId = treeNodes[i].Parent == null ? -1 : treeNodes.IndexOf(treeNodes[i].Parent as ComparisonCategoryTreeNode);
        if (parentId != -1) {
            ComparisonCategory comparisonCategory = treeNodes[i].comparisonCategory;
            comparisonCategory.categoryParentId = parentId;
            comparisonCategory.categoryId = i;
            InserNewCategory(comparisonCategory, transaction, conn);
            //  BackEndUtils.InsertFolderName(i, treeNodes[i].Text, parentId, transaction, conn);
        } else {
            ComparisonCategory comparisonCategory = treeNodes[i].comparisonCategory;
            comparisonCategory.categoryParentId = parentId;
            comparisonCategory.categoryId = i;
            InserNewCategory(comparisonCategory, transaction, conn);
        }
        }
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:18,代码来源:Env_Comparison_Categories.cs


示例19: DeleteEnvResultsCategories

 private static void DeleteEnvResultsCategories(SqlCeTransaction transaction, SqlCeConnection conn)
 {
     SqlCeCommand command = new SqlCeCommand(Env_Comparison_Categories_SQL.commandDeleteAllEnvCategories, conn);
        command.Transaction = transaction;
        command.Connection = conn;
        command.ExecuteNonQuery();
 }
开发者ID:mzkabbani,项目名称:cSharpProjects,代码行数:7,代码来源:Env_Comparison_Categories.cs


示例20: CreateCommand

        /// <summary>
        /// Create a SqlCeCommand instance using the global SQL CE Connection instance and associate this with a transaction
        /// </summary>
        /// <param name="transaction">
        /// SqlCeTransaction to be used for the SqlCeCommand
        /// </param>
        /// <returns>
        /// The <see cref="SqlCeCommand"/>.
        /// </returns>
        public static SqlCeCommand CreateCommand(SqlCeTransaction transaction)
        {
            // TODO come up with a better way to check for the database file
            SqlCeCommand command;

                if (!File.Exists(ConfigurationSettings.AppSettings["DB_File"]))
                {
                    DatabaseFile.CreateDatabase();
                }
                command = Connection.CreateCommand();
            //try
            //{
            //    command = Connection.CreateCommand();
            //}
            //catch (SqlCeException notFound)
            //{

            //    if (notFound.Message.Contains("be found"))
            //    {

            //    }

            //    command = Connection.CreateCommand();
            //}

            command.Transaction = transaction;
            return command;
        }
开发者ID:novaksam,项目名称:CIS499_C-_IM_Package,代码行数:37,代码来源:EntityBase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SqlCommand类代码示例发布时间:2022-05-24
下一篇:
C# SqlCeParameter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap