Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Stored Proc name from table
Message
From
19/08/2014 13:05:25
 
 
To
19/08/2014 12:15:17
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01606070
Message ID:
01606074
Views:
43
>I don't know if this is even possible in c#, but I would like to be able to read in the name of a Stored Proc into a variable and then call it via that variable name
>
>Something along the lines of
>
>string SPName = Globals.GetConfiv("HBCSPName");
>DataSet GVSet = {I'm assuming I'd need to cast it as something) SPName;
>
>How (if possible) would I do this?

Pretty straightforward (assuming you don't need parameters) since the relevant SQLCommand takes a string as the procedure name. e.g. using an SP to fill a dataset:
string SPName = "Test"
 var command = new SqlCommand(SPName, conn);

  SqlDataAdapter da = new SqlDataAdapter();
  da.SelectCommand = command;
  da.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
  DataSet dataset = new DataSet();
  da.Fill(dataset);
Previous
Reply
Map
View

Click here to load this message in the networking platform