Click here to Skip to main content
15,890,438 members
Articles / Web Development / ASP.NET
Article

Automation Helper for Stored Procedures in C#

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
18 Jul 2007CPOL1 min read 31K   263   32   5
Helper classes for automation of stored procedures

Introduction

I wrote this class library to help me construct a Visual Studio Addin to insert code into my editor based on the stored procedure and its parameters. The Addin uses XSLT to make the insertion code so the library is serializable and the XML produced can be used easily for XSLT transformations.

Background

The idea of the library is to make a collection of data objects that capture the parameter information from a SQL Server procedure and then use that data programmatically for whatever purpose.

Using the Code

The main class to use is the SQLServerProcProcessor class which takes a connection string to the server in the constructor.

There are two methods to get parameter data from a stored procedure name:

  1. GetParameterCollection(string strProcName), which returns a collection class of detailed information derived from the procedure. The XML file GetParameterCollection_results.xml has the serialize output from this method.
  2. GetParameters(string strProcName), which returns a List of much smaller collection of parameter information from the procedure. The file GetParameter_result.xml has the serialized output from this method.
C#
// Instantiating the main class
SQLServerProcProcessor sqlProcessor = new SQLServerProcProcessor(connStrTextBox.Text);

// Calling the methods
List<ParamInfo> paramInfos = sqlProcessor.GetParameters(procName);
SqlParameterCollection paramCollection = sqlProcessor.GetParameterCollection(procName);

Points of Interest

I am sure I don't know all the uses for a class like this, but it has served my needs. Let me know if there are some good uses you have found.

History

  • 18th July, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Website: http://www.somedeveloper.us

Comments and Discussions

 
GeneralUse of the Automation Helper for SP in C# Pin
JVanDamme25-Jul-07 6:04
JVanDamme25-Jul-07 6:04 
GeneralRe: Use of the Automation Helper for SP in C# Pin
JVanDamme30-Apr-08 8:27
JVanDamme30-Apr-08 8:27 
GeneralRe: Use of the Automation Helper for SP in C# Pin
Jeff Bramlett30-Apr-08 8:35
Jeff Bramlett30-Apr-08 8:35 
GeneralWhy not ... Pin
HRiazi18-Jul-07 18:45
HRiazi18-Jul-07 18:45 
GeneralRe: Why not ... Pin
Jeff Bramlett19-Jul-07 2:40
Jeff Bramlett19-Jul-07 2:40 
Thanks!

I think you mean using the DeriveParameters from the Enterprise library, which will certainly do the job.

I just did not want to distribute the Enterprise library with my Visual Studio Addin

Big Grin | :-D Smile | :)


Jeff Bramlett

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.