StoredProcedures with variable parameter list
-
I pass the name of the stored procedure into my function and then append the parameters the stored procedure expects. This works fine as long as I have stored procedures which expect always the same parameters. But now there are very few exceptions. So my question is if there is a way to check how many parameters a stored procedure is expecting before I execute it? Public Function GetReport(ByVal StoredProc As String) As Boolean Dim cmd As New SqlCommand(StoredProc, m_Conn) cmd.Parameters.Add(...) cmd.Parameters.Add(...) Many thanks for all kind of hints Andreas
-
I pass the name of the stored procedure into my function and then append the parameters the stored procedure expects. This works fine as long as I have stored procedures which expect always the same parameters. But now there are very few exceptions. So my question is if there is a way to check how many parameters a stored procedure is expecting before I execute it? Public Function GetReport(ByVal StoredProc As String) As Boolean Dim cmd As New SqlCommand(StoredProc, m_Conn) cmd.Parameters.Add(...) cmd.Parameters.Add(...) Many thanks for all kind of hints Andreas
You can pass a Dictionary, where the keys are the parameter names and the values are the parameters. Otherwise, no. You can't ask how many are expected, and if you're calling a proc, you really need to know ( who cares how many it expects if you don't have values to pass through to it ? )
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
You can pass a Dictionary, where the keys are the parameter names and the values are the parameters. Otherwise, no. You can't ask how many are expected, and if you're calling a proc, you really need to know ( who cares how many it expects if you don't have values to pass through to it ? )
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
That's true :) Thanks