Click here to Skip to main content
Licence CPOL
First Posted 18 Jul 2007
Views 14,449
Downloads 136
Bookmarked 30 times

Automation Helper for Stored Procedures in C#

By | 18 Jul 2007 | Article
Helper classes for automation of stored procedures
 
Part of The SQL Zone sponsored by
See Also

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jeff Bramlett

Software Developer (Senior)

United States United States

Member

Website: http://www.devbyjeffbramlett.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralUse of the Automation Helper for SP in C# PinmemberJVanDamme6:04 25 Jul '07  
GeneralRe: Use of the Automation Helper for SP in C# PinmemberJVanDamme8:27 30 Apr '08  
GeneralRe: Use of the Automation Helper for SP in C# PinmemberJeff Bramlett8:35 30 Apr '08  
GeneralWhy not ... PinmemberH.Riazi18:45 18 Jul '07  
GeneralRe: Why not ... PinmemberJeff Bramlett2:40 19 Jul '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 18 Jul 2007
Article Copyright 2007 by Jeff Bramlett
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid