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


C# IDbCommand.Prepare方法代码示例

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


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

示例1: DbPreparedCommand

 public DbPreparedCommand([NotNull] IDbConnection connection, [CanBeNull] IDbTransaction transaction, [NotNull] string sql, [CanBeNull] object parameters)
 {
     _Command = connection.CreateCommand();
     _Command.Transaction = transaction;
     _Command.CommandText = sql;
     _PropertiesAndParameters = CreateParameterMapping(_Command, parameters);
     AssignParameters(parameters);
     _Command.Prepare();
 }
开发者ID:modulexcite,项目名称:Sequel,代码行数:9,代码来源:DbPreparedCommand.cs

示例2: ExecuteReader

        static IDataReader ExecuteReader(IDbCommand sql)
        {
            IDataReader result = null;
             using (var db = CreateConnection())
             {
            db.Open();
            sql.Connection = db;
            sql.Prepare();
            result = sql.ExecuteReader();
            db.Close();
             }

             return result;
        }
开发者ID:pimanac,项目名称:ConsensusBot,代码行数:14,代码来源:Database.cs

示例3: ExecuteNonQuery

 static int ExecuteNonQuery(IDbCommand sql)
 {
     var result = -1;
      using (var db = CreateConnection())
      {
     db.Open();
     sql.Connection = db;
     sql.Prepare();
     sql.ExecuteNonQuery();
     sql.CommandText = "SELECT last_insert_rowid()";
     result = Int32.Parse(sql.ExecuteScalar().ToString());
     db.Close();
      }
      return result;
 }
开发者ID:pimanac,项目名称:ConsensusBot,代码行数:15,代码来源:Database.cs

示例4: Build

        /// <summary>
        /// Creates a database command object to execute
        /// </summary>
        /// <returns></returns>
        public IDbCommand Build()
        {
            if (ConnectionIsActive())
                throw new InvalidOperationException(string.Format("Database connection '{0}' is active; this state is invalid to execute the Build command", myConnectionString));

            myConnection = NewConnection();
            myConnection.ConnectionString = myConnectionString;
            myConnection.Open();

            myCommand = myConnection.CreateCommand();
            myCommand.CommandType = CommandType.Text;

            if (!string.IsNullOrEmpty(mySql))
                myCommand.CommandText = mySql;

            foreach (var param in Parameters)
                myCommand.Parameters.Add(param.Value);

            if (myServerPrepare)
                myCommand.Prepare();

            return myCommand;
        }
开发者ID:jdruin,项目名称:Wolfpack-Redux,代码行数:27,代码来源:AdhocCommandBase.cs

示例5: ExecuteNonQuery

        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public bool ExecuteNonQuery(IDbCommand command)
        {
            bool returnValue = false;

            if (command != null)
            {
                command.Prepare();
                command.ExecuteNonQuery();
                returnValue = true;
            }

            return returnValue;
        }
开发者ID:krishnarajv,项目名称:Code,代码行数:18,代码来源:SqlCEDataProvider.cs

示例6: PrepareCommand

		public void PrepareCommand(IDbCommand command)
		{
			AdjustCommand(command);
			OnBeforePrepare(command);

			if (SupportsPreparingCommands && prepareSql)
			{
				command.Prepare();
			}
		}
开发者ID:rytmis,项目名称:nhibernate-core,代码行数:10,代码来源:DriverBase.cs

示例7: PrepareCommand

		public void PrepareCommand(IDbCommand command)
		{
			if (SupportsPreparingCommands && prepareSql)
			{
				command.Prepare();
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:7,代码来源:DriverBase.cs

示例8: Prepare

		/// <summary>
		/// Prepares the <see cref="IDbCommand"/> for execution in the database.
		/// </summary>
		/// <param name="command"></param>
		/// <remarks>
		/// This takes care of hooking the <see cref="IDbCommand"/> up to an <see cref="IDbConnection"/>
		/// and <see cref="IDbTransaction"/> if one exists.  It will call <c>Prepare</c> if the Driver
		/// supports preparing commands.
		/// </remarks>
		private void Prepare( IDbCommand command )
		{
			try
			{
				Log( command );

				if( command.Connection != null )
				{
					// make sure the commands connection is the same as the Sessions connection
					// these can be different when the session is disconnected and then reconnected
					if( command.Connection != session.Connection )
					{
						command.Connection = session.Connection;
					}
				}
				else
				{
					command.Connection = session.Connection;
				}

				if( session.Transaction != null )
				{
					session.Transaction.Enlist( command );
				}

				if( factory.PrepareSql && factory.ConnectionProvider.Driver.SupportsPreparingCommands )
				{
					command.Prepare();
				}
			}
			catch( InvalidOperationException ioe )
			{
				throw new ADOException(
					"While preparing " + command.CommandText + " an error occurred"
					, ioe );
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:46,代码来源:BatcherImpl.cs

示例9: InitializeConnection

		void InitializeConnection()
		{
			if (cnc == null)
				CreateNewConnection();
			cnc.Open ();
			selectCommand = cnc.CreateCommand ();
			selectCommand.CommandText = selectCommandText;
			selectCommand.Parameters.Add (CreateParam (selectCommand, DbType.String, "SessionID", String.Empty));
			selectCommand.Parameters.Add (CreateParam (selectCommand, DbType.DateTime, "Expires", DateTime.MinValue ));
			selectCommand.Parameters.Add (CreateParam (selectCommand, DbType.String, "AppPath", String.Empty));
			selectCommand.Prepare ();
			
			insertCommand = cnc.CreateCommand ();
			insertCommand.CommandText = insertCommandText;
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.String, "SessionID", String.Empty));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.String, "AppPath", String.Empty));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.DateTime, "Created", DateTime.MinValue));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.DateTime, "Expires", DateTime.MinValue));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.Int32, "Timeout", 0));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.Binary, "StaticObjectsData",new byte[0] ));
			insertCommand.Parameters.Add (CreateParam (insertCommand, DbType.Binary, "SessionData",
						   new byte[0]));
			insertCommand.Prepare();
			
			updateCommand = cnc.CreateCommand ();
			updateCommand.CommandText = updateCommandText;
			updateCommand.Parameters.Add (CreateParam (updateCommand, DbType.String, "SessionID", String.Empty));
			updateCommand.Parameters.Add (CreateParam (updateCommand, DbType.DateTime, "Expires", DateTime.MinValue));
			updateCommand.Parameters.Add (CreateParam (updateCommand, DbType.Int32, "Timeout", 0));
			updateCommand.Parameters.Add (CreateParam (updateCommand, DbType.Binary, "SessionData",
								new byte[0]));
			updateCommand.Prepare();
			
			deleteCommand = cnc.CreateCommand ();
			deleteCommand.CommandText = deleteCommandText;
			deleteCommand.Parameters.Add (CreateParam (deleteCommand, DbType.String, "SessionID", String.Empty));
			deleteCommand.Prepare();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:38,代码来源:SessionSQLServerHandler.cs

示例10: ExecuteNonQuery

 /// <summary>
 /// Returns True if command executed successfully else false
 /// </summary>
 /// <param name="command">SqlCommand object</param>
 /// <returns>True/False</returns>
 public bool ExecuteNonQuery(IDbCommand command)
 {
     command.Prepare();
     command.ExecuteNonQuery();
     return true;
 }
开发者ID:krishnarajv,项目名称:Code,代码行数:11,代码来源:SqlStorageProvider.cs


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