public string SqlStatement()
        {
            string result = DatabaseTriggers.SqlStatement();

            return(result);
            // TODO: add assertions to method DatabaseTriggersTest.SqlStatement()
        }
        public DatabaseTriggers Constructor(
            string triggerName,
            string triggerOwner,
            string tableSchema,
            string tableName,
            int update,
            int delete,
            int insert,
            int after,
            int insteadOf,
            int disabled
            )
        {
            DatabaseTriggers target = new DatabaseTriggers
                                          (triggerName, triggerOwner, tableSchema, tableName, update,
                                          delete, insert, after, insteadOf, disabled);

            return(target);
            // TODO: add assertions to method DatabaseTriggersTest.Constructor(String, String, String, String, Int32, Int32, Int32, Int32, Int32, Int32)
        }
Beispiel #3
0
        /// <summary>
        /// Gets the database triggers.
        /// </summary>
        /// <param name="database">The database.</param>
        /// <returns>the database triggers</returns>
        public List <DatabaseTriggers> GetDatabaseTriggers(string database)
        {
            this.ExecuteUseDatabase(database);

            List <DatabaseTriggers> results = new List <DatabaseTriggers>();
            DatabaseTriggers        resultrow;
            string sqlString = DatabaseTriggers.SqlStatement();

            sqlString = string.Format("EXEC sp_executesql @statement = N'{0}'", sqlString.Replace("'", "''"));

            using (SqlConnection connection = new SqlConnection(this.ConnectionString))
                using (SqlCommand command = new SqlCommand(sqlString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            resultrow = new DatabaseTriggers(
                                reader.GetString(reader.GetOrdinal("TriggerName")),
                                reader.GetString(reader.GetOrdinal("TriggerOwner")),
                                reader.GetString(reader.GetOrdinal("TableSchema")),
                                reader.GetString(reader.GetOrdinal("TableName")),
                                reader.GetInt32(reader.GetOrdinal("IsUpdate")),
                                reader.GetInt32(reader.GetOrdinal("IsDelete")),
                                reader.GetInt32(reader.GetOrdinal("IsInsert")),
                                reader.GetInt32(reader.GetOrdinal("IsAfter")),
                                reader.GetInt32(reader.GetOrdinal("IsInsteadOf")),
                                reader.GetInt32(reader.GetOrdinal("Disabled")));

                            results.Add(resultrow);
                        }
                    }

                    connection.Close();
                }

            return(results);
        }