How to retrieve stored procedure parameters?

  • Thread starter Thread starter aleko
  • Start date Start date
A

aleko

Hi,

I am looking for a way to programmatically determine the parameter list
of a storded procedure. In classic ASP this could be done using
cmd.Parameters.Refresh. How can this be done in .NET?

Thanks,

Aleko
 
You can use a SqlCommand to run the following T-SQL.



exec sp_procedure_params_rowset N'Stored Procedure Name', 1, N'dbo', NULL





Good luck,

Italo
 
Read will return false if the IDataReader doesn't have any rows.
Unfortunately IDataReader doesn't provide another method to do this.

Italo
 
Sorry, posted in wrong message.


Italo Silveira said:
Read will return false if the IDataReader doesn't have any rows.
Unfortunately IDataReader doesn't provide another method to do this.

Italo
 
This type of operation is typically reserved for those applications writing
data access/DML tools. Use of SPs to return SPs schema is very expensive.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Thanks for your help, guys.

Italo, I implemented your suggestion in a class, and it works like a
charm! Thank you.

Bill, you're right about the performance implications. To get around
this I'm using static SqlCommand objects in my data access classes, so
the parameter building process only needs to be done once at startup.

-Aleko
 
Back
Top