Click here to Skip to main content
15,881,812 members
Articles / Programming Languages / Visual Basic

Simulating Stored Procedures in Microsoft Access using Enterprise Library Application Blocks

Rate me:
Please Sign up or sign in to vote.
3.46/5 (12 votes)
25 Jul 2005MIT6 min read 98.2K   1.1K   37  
Simulating stored procedures in Microsoft Access using Enterprise Library Application Blocks.
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Data Access Application Block
//===============================================================================
// Copyright � Microsoft Corporation. All rights reserved.
// Adapted from ACA.NET with permission from Avanade Inc.
// ACA.NET copyright � Avanade Inc. All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System.Diagnostics;
using System.Management.Instrumentation;
using Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation;

namespace Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation
{
    /// <summary>
    /// <para>This type supports the Data Access Instrumentation infrastructure and is not intended to be used directly from your code.</para>
    /// </summary>    
    public class DataServiceEvent : BaseEvent
    {
        internal static CounterCreationData[] Counters = new CounterCreationData[]
            {
                new CounterCreationData(SR.NumConnPerSec, SR.NumConnPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumConnFailPerSec, SR.NumConnFailPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumCmdsPerSec, SR.NumCmdsPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumCmdsFailPerSec, SR.NumCmdsFailPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumTransOpenPerSec, SR.NumTransOpenPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumTransFailPerSec, SR.NumTransFailPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumTransCommitPerSec, SR.NumTransCommitPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.NumTransAbortPerSec, SR.NumTransAbortPerSecMsg, PerformanceCounterType.RateOfCountsPerSecond32),
                new CounterCreationData(SR.AvgCmdTime, SR.AvgCmdTimeMsg, PerformanceCounterType.AverageTimer32),
                new CounterCreationData(SR.TotalCmd, SR.TotalCmdMsg, PerformanceCounterType.AverageBase)
            };

        private InstrumentedEvent instrumentedEvent;
        private string message;

        /// <summary/>
        /// <exclude/>
        protected DataServiceEvent()
        {
            Message = string.Empty;
            InternalEvent = null;
        }

        /// <summary/>
        /// <param name="counterNames"/>
        /// <exclude/>
        protected DataServiceEvent(string[] counterNames)
        {
            Message = string.Empty;
            InternalEvent = new InstrumentedEvent(SR.CounterCategory, counterNames, true);
        }

        /// <summary/>
        /// <param name="counterNames"/>
        /// <param name="eventLogIds"/>
        /// <exclude/>
        protected DataServiceEvent(string[] counterNames, EventLogIdentifier[] eventLogIds)
        {
            Message = string.Empty;
            InternalEvent = new InstrumentedEvent(SR.CounterCategory, counterNames, true, SR.EventSource, eventLogIds);
        }

        /// <summary/>
        /// <exclude/>
        public string Message
        {
            get { return this.message; }
            set { this.message = value; }
        }

        /// <summary/>
        /// <exclude/>
        /// <devdoc>
        /// The internal event object responsible for the Performance Counters and
        /// the EventLog.  And, it constructed with a BaseEvent object, it also
        /// ties the WMI event when fired.
        /// </devdoc>
        protected InstrumentedEvent InternalEvent
        {
            get { return this.instrumentedEvent; }
            set { this.instrumentedEvent = value; }
        }

        /// <summary/>
        /// <param name="message"/>
        /// <exclude/>
        protected void FireAuxEvent(string message)
        {
            if (InternalEvent == null)
            {
                return;
            }

            InternalEvent.FireEvent(message);
        }

        /// <devdoc>
        /// Index to the Counters array.
        /// </devdoc>
        internal enum CounterIndex : int
        {
            ConnectionOpenned = 0,
            ConnectionFailed = 1,
            CommandExecuted = 2,
            CommandFailed = 3,
            TransactionOpenned = 4,
            TransactionFailed = 5,
            TransactionCommitted = 6,
            TransactionRolledBack = 7,
            AvgCommandExecuteTime = 8,
            TotalCommandExecuted = 9
        }

        /// <devdoc>
        /// Index to the Event Log array.
        /// </devdoc>   
        internal enum LogIndex : int
        {
            FailureOccurred = 1,
            ConnectionFailed = 10,
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions