Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Automation Helper for Stored Procedures in C#

0.00/5 (No votes)
18 Jul 2007 1  
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.
// 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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here