Looking for SQL2K Stored Procedure utility

B

Brian Simmons

Hi All,

Many moons ago, I remember the ASP.NET Pro magazine publishing an article
about a Winform utility that generated stored procedure .net calling code.

i.e. if you have stored proc had 5 params it would generate some text you
could copy & paste into your code, like this (just a sample, may be typos):
SqlCommand myComm = new SqlCommand("sp_test", myConn);
myComm.CommandType = CommandType.StoredProcedure;

SqlParameter emailParam = new SqlParameter("@Email",
SqlDbType.VarChar, 255);
SqlParameter passwordParam = new SqlParameter("@Password",
SqlDbType.VarChar, 255);
SqlParameter userIDParam = new SqlParameter("@UserID",
SqlDbType.Int);
userIDParam.Direction = ParameterDirection.Output;
SqlParameter isAdminParam = new SqlParameter("@IsAdmin",
SqlDbType.Bit);
isAdminParam.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@RETURN_VALUE",
SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;

myComm.Parameters.Add(emailParam);
myComm.Parameters.Add(passwordParam);
myComm.Parameters.Add(userIDParam);
myComm.Parameters.Add(isAdminParam);
myComm.Parameters.Add(returnValue);

Basically, it generated a pretty good skeleton of code that you could add
upon. You just picked the stored proc from a list of available ones, and it
clicked generate.

Anybody know of such a beast?

Thanks,
Brian
 
R

Rad [Visual C# MVP]

Hi All,

Many moons ago, I remember the ASP.NET Pro magazine publishing an article
about a Winform utility that generated stored procedure .net calling code.

i.e. if you have stored proc had 5 params it would generate some text you
could copy & paste into your code, like this (just a sample, may be typos):
SqlCommand myComm = new SqlCommand("sp_test", myConn);
myComm.CommandType = CommandType.StoredProcedure;

SqlParameter emailParam = new SqlParameter("@Email",
SqlDbType.VarChar, 255);
SqlParameter passwordParam = new SqlParameter("@Password",
SqlDbType.VarChar, 255);
SqlParameter userIDParam = new SqlParameter("@UserID",
SqlDbType.Int);
userIDParam.Direction = ParameterDirection.Output;
SqlParameter isAdminParam = new SqlParameter("@IsAdmin",
SqlDbType.Bit);
isAdminParam.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@RETURN_VALUE",
SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;

myComm.Parameters.Add(emailParam);
myComm.Parameters.Add(passwordParam);
myComm.Parameters.Add(userIDParam);
myComm.Parameters.Add(isAdminParam);
myComm.Parameters.Add(returnValue);

Basically, it generated a pretty good skeleton of code that you could add
upon. You just picked the stored proc from a list of available ones, and it
clicked generate.

Anybody know of such a beast?

Thanks,
Brian

You could use CodeSmith and write a template to generate this sort of code
for you. The API is pretty fully functional allowing you to derive a lot of
information about your database, tables and columns
 
W

WenYuan Wang [MSFT]

Hi Brian,
Thanks for Jim and Rad's suggestion.

CodeSmith should be a great tool for you.
I searched on
http://msdn.microsoft.com/msdnmag/code/codeDownload.aspx?year=07. However,
I did not find the tool which you mentioned in initial post. But, as far as
I know, there are some tools in MSDN and CODEPROJECT website. You may check
it. Hope this helps.
http://www.codeproject.com/cs/database/dbhelper.asp
[SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET]
http://msdn2.microsoft.com/en-us/library/ms973259.aspx
[Auto-Generating Wrapper Classes for Stored Procedures, Part 1: Using the
AutoSproc Tool]

Have a great day.
Sincerely,
Wen Yuan
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top