Printing parameter values from command object. vb.net

Does anyone have some sample code for vb.net (web ap), where you can pass an sql server command object have it print each parameter.

ie. I want to pass my cmd object to a sub routine, and for each parameter response.write(parameter name + parameter value)

thanks
Fraser_AdminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

soco180Commented:
Sorry this is in VB 6 (not .Net) but it should be similar.

Private Function ParamDump() As Long
On Error GoTo EH
Dim oParam As clsSpParam
Dim oCMD As ADODB.Command
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0
soco180Commented:
Oops, you wanted to pass the command object...

Private Function ParamDump(oCMD As ADODB.Command) As Long
On Error GoTo EH
Dim oParam As clsSpParam
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0
soco180Commented:
Sorry again. this is the last time (I hope)...I actually copied code from an app that I had previously wrote and deleted the other stuff. So I accidentally had a Class that I had built as a param wrapper, a class that you won't have.

Any here is my final VB 6 answer.

Private Function ParamDump(oCMD As ADODB.Command) As Long
On Error GoTo EH
Dim oPrm As ADODB.Parameter
Dim lParamCount As Long
    For Each oPrm In oCMD.Parameters
        Debug.Print oPrm.Name & " = '" & oPrm.Value & "'"
    Next
    ParamDump = lParamCount
End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fraser_AdminAuthor Commented:
Thanks that was exactly what i wanted.  This is converted to .net

Friend Sub ParamDump(ByVal oCMD As SqlCommand)
        Dim oPrm As SqlParameter
        For Each oPrm In oCMD.Parameters
            HttpContext.Current.Response.Write(oPrm.ParameterName & " = " & oPrm.Value & "<BR>")
        Next
    End Sub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.