[ Team LiB ] Recipe Getting Stored Procedure Parameter Information at Runtime Problem You want to get information about the parameters used by a stored procedure at runtime. Solution Use DeriveParameters( ) method of the CommandBuilder. | Team LiB Recipe Getting Stored Procedure Parameter Information at Runtime Problem You want to get information about the parameters used by a stored procedure at runtime. Solution Use DeriveParameters method of the CommandBuilder. With Microsoft SQL Server you could also use system stored procedures. The sample code demonstrates either one of these techniques as specified by the user. In either case the results are stored to a DataTable and its default view is bound to a data grid on the form. The C code is shown in Example 4-12. Example 4-12. File Namespaces variables and constants using System using using using using . . . String procedureName Sales by Year Create the table to hold the results. DataTable dt new DataTable if Build a command object for the Sales by Year stored procedure. SqlConnection conn new SqlConnection S ql_ConnectString SqlCommand cmd new SqlCommand procedureName conn Get the parameters. cmd Define table columns to hold the results. Name Direction SqlType Retrieve the results from the command object to the table. foreach SqlParameter param in new object Stored procedure procedureName parameters using else if Build a command object to use SQL Server stored procedure to retrieve parameters. SqlConnection conn new SqlConnection S ql_ConnectString SqlCommand cmd new SqlCommand sp_sproc_columns conn SqlParameter param @procedure_name 390 .