Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get Stored Proc name from table
Message
De
19/08/2014 13:05:25
 
 
À
19/08/2014 12:15:17
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01606070
Message ID:
01606074
Vues:
49
>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);
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform