Get stored procedure parameters by either C# or SQL?

前端 未结 4 970
你的背包
你的背包 2020-12-08 18:25

I was hoping to find an easy way to get a parameter list of a stored procedures parameters. If the procedure has 3 paramaters, I want a list like this:

param

4条回答
  •  天命终不由人
    2020-12-08 18:58

    If you're familiar with Enterprise Library, there's a good method which allows to DiscoverParameters(), using the Data Access Application Block.

    DbCommand command = new DbCommand();
    command.CommandText = @"myStoredProc";
    command.CommandType = CommandType.StoredProcedure;
    
    Database database = new SqlDatabase(myConnectionString);
    database.DiscoverParameters(command);
    // ...
    

    Some links that might help:

    1. DiscoverParameters Method;
    2. Microsoft.Practices.EnterpriseLibrary.Data Namespace.

    The above links refers to EntLib 3.1. Depending on the .NET Framework version you're using, you might also consider downloading the correct EntLib version for you following this link.

提交回复
热议问题