Click here to Skip to main content
15,892,697 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.3K   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.
// 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;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;

namespace Microsoft.Practices.EnterpriseLibrary.Data.Configuration.Design
{
    /// <summary>
    /// <para>
    /// Represents a connection string node for Oracle in the data settings for an application.
    /// </para>
    /// </summary>    
    public class OracleConnectionStringNode : ConnectionStringNode
    {
        private OracleConnectionStringData oracleConnectionStringData;

        /// <summary>
        /// <para>
        /// Initialize a new instance of the <see cref="OracleConnectionStringNode"/> class.
        /// </para>
        /// </summary>
        public OracleConnectionStringNode() : this(new OracleConnectionStringData(SR.DefaultOracleConnectionStringName))
        {
        }

        /// <summary>
        /// <para>Initalize a new instance of the <see cref="OracleConnectionStringNode"/> class with the runtime version that this node will represent.</para>
        /// </summary>
        /// <param name="oracleConnectionStringData">
        /// <para>The <see cref="OracleConnectionStringData"/> that this node will represent.</para>
        /// </param>
        public OracleConnectionStringNode(OracleConnectionStringData oracleConnectionStringData) : base(oracleConnectionStringData)
        {
            this.oracleConnectionStringData = oracleConnectionStringData;
        }

        /// <summary>
        /// <para>Gets the <see cref="OracleConnectionStringData"/> object that this node represents.</para>
        /// </summary>
        /// <value>
        /// <para>The <see cref="OracleConnectionStringData"/> object that this node represents.</para>
        /// </value>
        [Browsable(false)]
        public override ConnectionStringData ConnectionStringData
        {
            get
            {
                OracleConnectionStringData oracleConnectionString = (OracleConnectionStringData)base.ConnectionStringData;
                oracleConnectionString.OraclePackages.Clear();
                foreach (ConfigurationNode childNode in Nodes)
                {
                    OraclePackageNode oraclePackageNode = childNode as OraclePackageNode;
                    if (oraclePackageNode != null)
                    {
                        oracleConnectionString.OraclePackages.Add(oraclePackageNode.OraclePackage);
                    }
                }
                return oracleConnectionString;
            }
        }

        /// <summary>
        /// <para>
        /// Add the default child nodes for the current node.
        /// </para>
        /// </summary>
        /// <remarks>
        /// <para>
        /// This will add the default parameter nodes for the connection string.
        /// </para>
        /// </remarks>
        protected override void AddDefaultChildNodes()
        {
            // don't call base because I want to add my own nodes
            CreateDefaultParameterNode();
            CreateDefaultPackagesNode();
        }

        /// <summary>
        /// <para>Adds the base menu items and a menu item for creating <see cref="OraclePackageNode"/> objects.</para>
        /// </summary>
        protected override void OnAddMenuItems()
        {
            base.OnAddMenuItems ();
            ConfigurationMenuItem item = new ConfigurationMenuItem(SR.DefaultOraclePackageNodeName, new AddChildNodeCommand(Site, typeof(OraclePackageNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.DefaultOraclePackageNodeName), InsertionPoint.New);
            AddMenuItem(item);
        }


        /// <summary>
        /// <para>Sets the name of node when sited to match the underlying storage name.</para>
        /// </summary>
        protected override void OnSited()
        {
            base.OnSited();
            foreach (OraclePackageData oraclePackage in oracleConnectionStringData.OraclePackages)
            {
                Nodes.Add(new OraclePackageNode(oraclePackage));
            }
        }

        private void CreateDefaultParameterNode()
        {
            ParameterNode node = new ParameterNode(new ParameterData(SR.DefaultServerParameterName, SR.DefaultServerParameterName));
            Nodes.AddWithDefaultChildren(node);
        }

        private void CreateDefaultPackagesNode()
        {
            OraclePackageNode node = new OraclePackageNode();
            Nodes.AddWithDefaultChildren(node);
        }
    }
}

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