Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. StoredProcedures with variable parameter list

StoredProcedures with variable parameter list

Scheduled Pinned Locked Moved ASP.NET
questiondatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TeachesOfPeaches
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • T TeachesOfPeaches

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      T 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        T Offline
        T Offline
        TeachesOfPeaches
        wrote on last edited by
        #3

        That's true :) Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups