SetupCommand() public method

Sets up the IDbCommand object
public SetupCommand ( IDbCommand command ) : void
command IDbCommand The command
return void
コード例 #1
0
ファイル: Database.cs プロジェクト: kevinbosman/habanero
 /// <summary>
 /// Executes the given sql statement using the database connection 
 /// provided
 /// </summary>
 /// <param name="statement">The sql statement</param>
 /// <param name="connection">The database connection</param>
 public static void ExecuteSqlStatement(SqlStatement statement, IDbConnection connection)
 {
     if (statement == null) throw new ArgumentNullException("statement");
     if (connection == null) throw new ArgumentNullException("connection");
     if (connection.State != ConnectionState.Open)
     {
         connection.Open();
     }
     IDbCommand cmd = connection.CreateCommand();
     statement.SetupCommand(cmd);
     cmd.ExecuteNonQuery();
 }
コード例 #2
0
 public void SetupTestFixture()
 {
     var config = new DatabaseConfig(DatabaseConfig.SqlServer, "test", "test", "test", "test", "1000");
     _connection = new DatabaseConnectionFactory().CreateConnection(config);
     _testStatement = new SqlStatement(_connection);
     _rawStatement = "insert into tb1 (field1, field2, field3) values (@Param1, @Param2, @Param3)";
     _testStatement.Statement.Append(_rawStatement);
     _addedParameter = _testStatement.AddParameter("Param1", "12345");
     _testStatement.AddParameter("Param2", "67890");
     _testStatement.AddParameter("Param3", "13579");
     _command = _connection.GetConnection().CreateCommand();
     _testStatement.SetupCommand(_command);
 }
コード例 #3
0
ファイル: Database.cs プロジェクト: SaberZA/habanero
        /// <summary>
        /// Executes the given sql statement using the database connection
        /// provided
        /// </summary>
        /// <param name="statement">The sql statement</param>
        /// <param name="connection">The database connection</param>
        public static void ExecuteSqlStatement(SqlStatement statement, IDbConnection connection)
        {
            if (statement == null)
            {
                throw new ArgumentNullException("statement");
            }
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            IDbCommand cmd = connection.CreateCommand();

            statement.SetupCommand(cmd);
            cmd.ExecuteNonQuery();
        }