Solved

Printing parameter values from command object.  vb.net

Posted on 2007-04-10
4
237 Views
Last Modified: 2010-04-14
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
0
Comment
Question by:Fraser_Admin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

by:soco180
ID: 18884924
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
 
LVL 2

Expert Comment

by:soco180
ID: 18884935
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
 
LVL 2

Accepted Solution

by:
soco180 earned 500 total points
ID: 18884962
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
 

Author Comment

by:Fraser_Admin
ID: 18890168
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question