﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Question about executing stored procedures dynamically...</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 20:35:26 GMT</lastBuildDate><ttl>20</ttl><item><title>Question about executing stored procedures dynamically...</title><link>http://forum.strataframe.net/FindPost15484.aspx</link><description>Consider that I have a table like this:&lt;br&gt;
&lt;br&gt;
ColumnName: Stored Procedure Name&lt;br&gt;
            InsertRecord&lt;br&gt;
            DeleteRecord&lt;br&gt;
            UpdateRecord&lt;br&gt;
&lt;br&gt;
What I want to be able to do is iterate through the table and execute the stored procedures at run time. The stored procedures though have a different number of parameters. InsertRecord has only one parameter, while DeleteRecord has two, etc.&lt;br&gt;
&lt;br&gt;
How could I do this in code? Obviously I dont want to have to hard code the parameters in the VB code.&lt;br&gt;
&lt;br&gt;
Should I use the DeriveParameters command? What would be the best way to execute these stored procedures when the parameters are unknown?&lt;br&gt;
&lt;br&gt;
Thanks :-D</description><pubDate>Thu, 10 Apr 2008 08:02:10 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Question about executing stored procedures dynamically...</title><link>http://forum.strataframe.net/FindPost15497.aspx</link><description>The SQLCommandBuilder is good and it may get you want you want.&amp;nbsp; That is also the very purpose of the DerivedParmameters...this class just has some limitations and can produce unoptimized queries...so that is the only thing I would caution about.</description><pubDate>Thu, 10 Apr 2008 08:02:10 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Question about executing stored procedures dynamically...</title><link>http://forum.strataframe.net/FindPost15495.aspx</link><description>Thanks for the info Trent. I found something called SQLCommandBuilder.DeriveParameters last night and I'm going to look into it... might be what I need. ;-D Just thought I would post this in case it helps anyone else or someone else has used it and can confirm its what I need.</description><pubDate>Thu, 10 Apr 2008 06:54:12 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Question about executing stored procedures dynamically...</title><link>http://forum.strataframe.net/FindPost15488.aspx</link><description>Well, like anything else, this can be done but the reason may change the approach.&amp;nbsp; You are going to need to know the number of parameters and the sprocs.&amp;nbsp; You can always query server for the sprocs and create a class that parses this information.&amp;nbsp; You would probably want to look at the sysobjects table.&amp;nbsp; It would be something like this (I'm just shootin from the hip here, so you may need to play with this a bit):&lt;/P&gt;&lt;P&gt;[codesnippet]Select * from sysobjects where type = 'P' and category = 0[/codesnippet]&lt;/P&gt;&lt;P&gt;You can then start digging a little deeper to get the parms, etc. and build a logical command with the parameters, etc.</description><pubDate>Wed, 09 Apr 2008 22:20:31 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>